Advertisement
Guest User

Untitled

a guest
May 6th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4.  
  5. using namespace std;
  6. struct Drzava
  7. {
  8.     char ime[15];
  9.     int prebivalci;
  10.     char mesto[15];
  11.  
  12. };
  13. void vpis(struct Drzava x[],int n);
  14. void izpis(struct Drzava x[],int n);
  15. void sortiranje(struct Drzava x[],int n);
  16. void iskanje(struct Drzava x[],int n);
  17. int main()
  18. {struct Drzava x[4];
  19.     vpis(x,4);
  20.     sortiranje(x,4);
  21.     izpis(x,4);
  22.     return 0;
  23. }
  24.  
  25. void vpis(struct Drzava x[],int n)
  26. {int i,j;
  27.     for(i=0;i<n;i++)
  28.     {cout<<"ime drzave:";
  29.         gets(x[i].ime);fflush(stdin);cout<<endl;
  30.         cout<<"st prebivalcev:";
  31.         cin>>x[i].prebivalci;fflush(stdin);cout<<endl;
  32.         if(x[i].prebivalci<50000) cout<<"Je to sploh drzava?"<<endl;
  33.         else ;
  34.         cout<<"glavno mesto:";
  35.         gets(x[i].mesto);fflush(stdin);cout<<endl;
  36.     }
  37. }
  38. void izpis(struct Drzava x[],int n)
  39. {int i;
  40.     for(i=0;i<n;i++)
  41.     {puts(x[i].ime);
  42.         cout<<endl;
  43.         cout<<"st. prebivalcev:"<<x[i].prebivalci;
  44.         cout<<endl;
  45.         cout<<"Glavno mesto:";
  46.         puts(x[i].mesto);
  47.         cout<<endl;
  48.         cout<<"-----------------"<<endl;
  49.  
  50.  
  51. }
  52. }
  53. void sortiranje(struct Drzava x[],int n)
  54. {
  55.     int i,j;
  56.     struct Drzava b;
  57.     for(j=0;j<n;j++)
  58.     {
  59.         for(i=0;i<n;i++)
  60.             if(strcmp(x[i].ime,x[i+1].ime)>0){
  61.                 b=x[i];
  62.                 x[i]=x[i+1];
  63.                 x[i+1]=b;
  64.             }
  65.     }
  66.  
  67. }
  68. void iskanje(struct Drzava x[],int n)
  69. {int i,j;
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement