Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string.h>
- using namespace std;
- struct osoba
- {
- string ime;
- string adresa;
- int god;
- };
- int main()
- {
- struct osoba a[10];
- int i = 0, n = 0, j, d, br;
- ifstream ul("ulaz.txt");
- ofstream iz("izlaz.txt");
- while(!ul.eof())
- {
- ul>>ws;
- getline(ul, a[i].ime);
- getline(ul, a[i].adresa);
- ul>>a[i].god;
- i++;
- }
- n = i - 1;
- cout<<n<<endl;
- for(i = 0; i < n-1; i++)
- for(j = i+1; j < n; j++)
- if(a[i].god > a[j].god)
- swap(a[i], a[j]);
- cout<<"Sortirani po godinamna"<<endl;
- for(i = 0; i < n; i++)
- cout<<a[i].ime<<" "<<a[i].adresa<<" "<<a[i].god<<endl;
- cout<<"Sa 3 ili vise slova 'A' ili 'a' u imenu"<<endl;
- for(i = 0; i < n; i++)
- {
- d = a[i].ime.size();
- br = 0;
- for(j = 0; j < d; j++)
- if(a[i].ime.substr(j,1) == "a" || a[i].ime.substr(j,1) == "A") br++;
- if(br >= 3)
- {
- iz<<a[i].ime<<"\t"<<a[i].adresa<<"\t"<<a[i].god<<endl;
- cout<<a[i].ime<<"\t"<<a[i].adresa<<"\t"<<a[i].god<<endl;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement