111
#include "stdlib.h"
#include "string.h"
#include <iostream>
#include "conio.h"
#include <fstream>
#include "windows.h"
using namespace std;
struct simple
{
char fam[30];
int iq;
};
struct full
{
simple a;
full *next;
};
full *first;
void add_first()
{
full *new_ = new full;
cout << "Введите имя ";
cin.getline(new_->a.fam, 30);
cout << "Введите iq ";
cin >> new_->a.iq;
new_->next = first;
first = new_;
}
void add_last()
{
full *new_ = new full;
full *p = new full;
p = first;
cout << "Введите имя ";
cin.getline(new_->a.fam, 30);
cout << "Введите iq ";
cin >> new_->a.iq;
while (p->next != NULL)
{
p = p->next;
}
p->next = new_;
new_ ->next=NULL;
}
void add_middle(full first)
{
}
void main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
ofstream f;
f.open("c:/temp/iq.txt", ios_base::app);
simple a;
do
{
system("cls");
cin.get();
cout << "Введите имя ";
cin.getline(a.fam, 30);
cout << "Введите iq ";
cin >> a.iq;
f << a.fam << " " << a.iq << endl;
} while (_getch() != 27);
f.close();
ifstream f1;
f1.open("c:/temp/iq.txt", ios_base::in);
full *p = new full;
p->next = NULL;
f1 >> p->a.fam >> p->a.iq;
first = p;
while (!f1.eof())
{
full *q = new full;
f1 >> q->a.fam >> q->a.iq;
q->next = NULL;
p->next = q;
p = p->next;
}
f1.close();
p = first;
while (p->next != NULL)
{
cout << p->a.fam << " " << p->a.iq << endl;
p = p->next;
}
cin.get();
char ff[30];
cout << "Введите фамилию ";
cin.getline(ff, 30);
p = first;
full *q = new full;
add_first();
add_last();
p = first;
while (p->next != NULL)
{
cout << p->a.fam << " " << p->a.iq << endl;
p = p->next;
}
system("pause");
}