Advertisement
rotti321

Teorie Informatica IX [declarare, citire, comparare, parcurgere interval]

May 2nd, 2022
1,186
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a,b,i,aux,suma=0,maxx;
  8.     double media;
  9.     cin>>a>>b;
  10.     media=(a+b)/2.0;
  11.     cout<<media<<endl;
  12.     if(a>b){
  13.         maxx=a;
  14.     }
  15.     else{
  16.         maxx=b;
  17.     }
  18.     if(a>b){ ///fanta-cola interschimbare
  19.         aux=a;
  20.         a=b;
  21.         b=aux;
  22.     }
  23.     for(i=a;i <= b;i++){ ///parcurg intervalul [a,b]
  24.             /// i++ <=> i=i+1
  25.         if(i>=42)    /// < <= > >= == !=
  26.             suma = suma + i; /// + - * / %
  27.     }
  28.     cout<<suma;
  29.     return 0;
  30. }
  31.  
Advertisement
RAW Paste Data Copied
Advertisement