Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <fstream>
- #include <iostream>
- using namespace std;
- struct gamers
- {
- char Name[30];
- int coin;
- int status;
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int sap;
- cout << "Введите количество футбольных команд : ";
- cin >> sap;
- gamers *pas = new gamers[sap];
- for(int i(0); i < sap; i++)
- {
- cin.sync();
- cout << "Введите название команды:";
- cin.getline(pas[i].Name,30);
- cout << "Введите количество очков команды " << pas[i].Name << ":";
- cin >> pas[i].coin;
- cout << "К какой группе относится команда " << pas[i].Name << " (1-сильная,2-слабая):";
- cin >> pas[i].status;
- cin.get();
- system("cls");
- }
- ofstream outfile;
- outfile.open("cppstudio.txt");
- for(int i(0); i < sap; i++)
- {
- outfile << pas[i].Name << 't' << pas[i].coin << 't' << pas[i].status << 'n';
- }
- outfile.close();
- delete [] pas;
- system("pause");
- return 0;
- }
- void main(int N, char** f)
- { int i,j,n=0;
- string buf;
- ifstream in("Voter_1.txt");
- ofstream out("Voter_2.txt");
- while (getline(in,buf)) n++;
- printf("n = %d n",n);
- rewind(in);
- string* S= new string[n];
- for (i=0;i<n;i++) getline(in,S[i]);// с этого момента со списком можно работать как с обычным массивом строк, к примеру, который можно разбить на массив из 3х слов - название, очки и группа.
- for (i=0;i<n-1;i++)
- for (j=0;j<n-1;j++) if (S[j]>S[j+1]) swp(S[j],S[j+1]);
- for (i=0;i<n;i++) out << S[i] << endl;
- delete[] S;
- puts("$$$$$$$$ CHA CHING $$$$$$$$");
- pause;
- }
Add Comment
Please, Sign In to add comment