Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- struct Drzava
- {
- char ime[15];
- int prebivalci;
- char mesto[15];
- };
- void vpis(struct Drzava x[],int n);
- void izpis(struct Drzava x[],int n);
- void sortiranje(struct Drzava x[],int n);
- void iskanje(struct Drzava x[],int n);
- int main()
- {struct Drzava x[4];
- vpis(x,4);
- sortiranje(x,4);
- izpis(x,4);
- return 0;
- }
- void vpis(struct Drzava x[],int n)
- {int i,j;
- for(i=0;i<n;i++)
- {cout<<"ime drzave:";
- gets(x[i].ime);fflush(stdin);cout<<endl;
- cout<<"st prebivalcev:";
- cin>>x[i].prebivalci;fflush(stdin);cout<<endl;
- if(x[i].prebivalci<50000) cout<<"Je to sploh drzava?"<<endl;
- else ;
- cout<<"glavno mesto:";
- gets(x[i].mesto);fflush(stdin);cout<<endl;
- }
- }
- void izpis(struct Drzava x[],int n)
- {int i;
- for(i=0;i<n;i++)
- {puts(x[i].ime);
- cout<<endl;
- cout<<"st. prebivalcev:"<<x[i].prebivalci;
- cout<<endl;
- cout<<"Glavno mesto:";
- puts(x[i].mesto);
- cout<<endl;
- cout<<"-----------------"<<endl;
- }
- }
- void sortiranje(struct Drzava x[],int n)
- {
- int i,j;
- struct Drzava b;
- for(j=0;j<n;j++)
- {
- for(i=0;i<n;i++)
- if(strcmp(x[i].ime,x[i+1].ime)>0){
- b=x[i];
- x[i]=x[i+1];
- x[i+1]=b;
- }
- }
- }
- void iskanje(struct Drzava x[],int n)
- {int i,j;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement