tehlurk

vjezba3

Mar 27th, 2013
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     //1
  8.     int a;
  9.     cout<<"Unesi cijeli broj:";
  10.     cin>>a;
  11.    
  12.     for(int i=1;i<=a;i++)
  13.     {
  14.         cout<<i<<" ";
  15.     }
  16.     cout<<endl;
  17.    
  18.     //2
  19.     float b;
  20.     float c=0;
  21.     float ar;
  22.     for(int i=1;i<=5;i++)
  23.     {
  24.         cout<<"Unesi broj:";
  25.         cin>>b;
  26.         c+=b;
  27.     }
  28.     ar=c/5;
  29.     cout<<"\nSuma iznosi:"<<c;
  30.     cout<<"\nAritmeticka sredina iznosi:"<<ar;
  31.    
  32.     //3
  33.     int d;
  34.     int e;
  35.     cout<<"\n\nUnesi jedan cijeli broj:";
  36.     cin>>d;
  37.     d=~d;
  38.     cout<<"\nKomplement unesenog broja je:"<<d<<endl;
  39.     cout<<"\nUnesi drugi cijeli broj:";
  40.     cin>>e;
  41.     e<<=5;
  42.     cout<<"\nBroj sa pomaknutim bitovima je:"<<e<<endl<<endl;
  43.    
  44.     //4
  45.     int f;
  46.     for(int i=1;i<=5;i++)
  47.     {
  48.         cout<<"Unesi broj:";
  49.         cin>>f;
  50.         if(f==3){
  51.             cout<<"\nPogodak!";
  52.             goto k;
  53.         }
  54.         else if(i==5 && f!=3)
  55.             cout<<"\nPogreska!";
  56.     }
  57.    
  58.     //5
  59.     k:int g;
  60.     cout<<"\n\nUnesi cijeli broj izmedu 10 i 20:"<<endl;
  61.     cin>>g;
  62.     if(g<10 || g>20)
  63.         cout<<"\nBroj nije u zadanom rasponu!"<<endl;
  64.     else{
  65.         for(int i=1;i<=g;i++)
  66.         {
  67.             if(i%2 != 0)
  68.                 continue;
  69.             cout<<i<<" ";
  70.         }
  71.     }
  72.     cout<<endl;
  73.    
  74.     system ("pause");
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment