Помогите без шаблона решить?Работая с использованием динамических переменных.Работа со списком. 1)Помогите с решением нескольких задач, как заменить функцию strcpy(p->FIO, Fio);? 2)Не считает AddFirst(Second,p->nomer,p->FIO); в функции void InputList2(PNode First,PNode Second)? 3)разобраться с массивом фамилия. Code: #include <iostream> #include <string.h> #include <conio.h> #include <windows.h> struct Student; typedef Student* PNode; using namespace std; struct Student { int nomer; char FIO[60]; PNode Next; }; void AddFirst(PNode& First,int nomer,char Fio[20]) { PNode p= new Student; p->nomer=nomer; strcpy(p->FIO, Fio); p->Next = First; First=p; } void InputList1(PNode& First) { int n; char Fio[60]; cout<<"Ведите колличество студентов: "; cin>>n; for (int i=1;i<=n;i++) { cout<<"Ввдите фио " << i << " студента: "; cin >> Fio; AddFirst(First,i,Fio); } } void PrintList1(PNode First) { PNode p=First; while (p) { cout<< p->nomer << ' ' << p->FIO <<endl; p=p->Next; } cout<<endl; } void InputList2(PNode First,PNode Second) { int K; cout << "Введите число пересчета К: "; cin >> K; PNode p = First; int i=0; while (p) { //cout<< i++<<p->FIO; if (p->nomer%K==0) { cout << "nashel"<< endl; AddFirst(Second,p->nomer,p->FIO); } p=p->Next; } } void main() { SetConsoleCP(1251); SetConsoleOutputCP(1251); PNode First = NULL; InputList1(First); PrintList1(First); PNode Second = NULL; InputList2(First,Second); PrintList1(Second); getch(); }
Спасибо формучане,что помогли быстро решить мою программу. Исходник задачи. Code: #include <iostream> #include <string> #include <windows.h> #include <conio.h> struct Student; typedef Student* PNode; using namespace std; struct Student{ int nomer; string FIO; PNode Next; }; void AddFirst(PNode& First,int nomer,string Fio){ PNode p= new Student; p->nomer=nomer; p->FIO = Fio; p->Next = First; First=p; } void InputList1(PNode& First){ int n; string Fio; cout<<"введит номер студента: "; cin>>n; for (int i=1;i<=n;i++){ cout<<"Введите ФИО " << i << " student: "; cin >> Fio; AddFirst(First,i,Fio); } } void PrintList1(PNode &First){ PNode p=First; while (p) { cout<< p->nomer << ' ' << p->FIO <<endl; p=p->Next; } cout<<endl; } void InputList2(PNode &First,PNode &Second){ int K; cout << "Введите К: "; cin >> K; PNode p = First; int i=0; while (p){ //cout<< i++<<p->FIO; if (p->nomer%K==0){ AddFirst(Second,p->nomer,p->FIO); } p=p->Next; } } void main(){ SetConsoleCP(1251); SetConsoleOutputCP(1251); PNode First = NULL; InputList1(First); PrintList1(First); PNode Second = NULL; InputList1(Second); PrintList1(Second); InputList2(First,Second); PrintList1(Second); getch(); }