Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- Void Wpisz(int ile)
- {
- ofstream fout("studenci.txt");
- string tab[ile][5];
- for(int i=0;i<ile;i++)
- {
- cout<<endl<<"Student nr "<<i+1<<": "<<endl;
- cout<<"Nazwisko: ";cin>>tab[i][0];
- cout<<"Imie: ";cin>>tab[i][1];
- cout<<"Wiek: ";cin>>tab[i][2];
- cout<<"Miejsce urodzenia: ";cin>>tab[i][3];
- cout<<"Telefon: ";cin>>tab[i][4];
- }
- for(int i=0;i<ile;i++)
- {
- fout<<tab[i][0]<<" "<<tab[i][1]<<" "<<tab[i][2]<<" "<<tab[i][3]<<" "<<tab[i][4]<<endl;
- }
- }
- int main()
- {
- int ile;
- cout<<"Ile studentow: ";cin>>ile;
- wpisz(ile);
- ifstream fin("studenci.txt");
- while(!fin.eof())
- {
- string nazwisko,imie,miejsce,telefon;
- int wiek;
- fin>>nazwisko>>imie>>wiek>>miejsce>>telefon;
- cout<<nazwisko<<" "<<imie<<" "<<wiek<<" "<<miejsce<<" "<<telefon<<endl;
- }
- cout<<endl<<"c)"<<endl;
- ifstream fin2("studenci.txt");
- float srednia = 0;
- while(!fin2.eof())
- {
- string nazwisko,imie,miejsce,telefon;
- int wiek;
- fin2>>nazwisko>>imie>>wiek>>miejsce>>telefon;
- cout<<nazwisko<<" "<<telefon<<endl;
- srednia+=wiek;
- }
- srednia/=ile;
- cout<<endl<<"d)"<<srednia;
- cout<<endl<<"e)";
- ifstream fin3("studenci.txt");
- while(!fin3.eof())
- {
- string nazwisko,imie,miejsce,telefon;
- int wiek;
- fin3>>nazwisko>>imie>>wiek>>miejsce>>telefon;
- if(nazwisko[0]=='A')cout<<imie<<" "<<nazwisko;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement