Есть программа которая записывает структуру в файл:
| Код | #include <stdio.h> #include <string> #include <iostream> #include <fstream> using namespace std; struct sportTeam { string name; string cityname; int players; int points;} ; int main() { int quan, n; sportTeam *team; cout << "Input a quantity of teams\t"; cin >> quan; team = new sportTeam[quan]; //--------------------------------------------------------------- // ПИШЕМ В ФАЙЛ //---------------------------------------------------------- ofstream ourfile; ourfile.open("fileOne2.txt",ios::app); for(int i = 0 ;i < quan;i++){ cout << "Input a name of " << (i+1)<<" team\t"; cin >> team[i].name; ourfile << (i+1) << " team's name : " << team[i].name << '\n'; cout << "Name of city\t"; cin >> team[i].cityname; ourfile << "Name of city : " << team[i].name << '\n'; cout << "Input a quantity of players : "; cin >> team[i].players; ourfile << "Quantity of players : " << team[i].players << '\n'; cout << "Input a points : "; cin >> team[i].points; ourfile << "Quantity of points : " << team[i].points << '\n';} ourfile.close(); cout << endl;
cout << "Kolichestvo ochek: "; cin >> n;
//--------------------------------------------------------------- // ЧИТАЕМ ФАЙЛ //---------------------------------------------------------- string mystring; ifstream ourfile2; ourfile2.open("fileOne2.txt"); while(!ourfile2.fail()){ getline(ourfile2,mystring); cout << mystring << endl;} ourfile2.close(); delete[] team; system("pause"); }
|
В файл записываться структура:
Спортивная команда": - название; - город; - количество игроков; - количество очек.
Нужно удалить из файла команды, у которой очек меньше чем задаёт пользователь.
1) Записать в файл команды [готово] 2) Спросить максимальное количество очек [готово] 3) Удалить команды у которых меньше очек чем задал пользователь [проблема] |