23.1.23020054. Generisati 3 dvocifrena broja. Naći sumu manjih od 35 i sumu većih od 65.
Opis rješenja:
Listing programa:
//23020054
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
srand(time(NULL));
int a=rand()%89+10,b=rand()%89+10,c=rand()%89+10;
int suma1=0,suma2=0;
cout<<a<<" "<<b<<" "<<c<<endl;
if(a < 35){
suma1=suma1+a;
}
if(b < 35){
suma1=suma1+b;
}
if(c < 35){
suma1=suma1+c;
}
if(a > 65){
suma2=suma2+a;
}
if(b > 65){
suma2=suma2+b;
}
if(c > 65){
suma2=suma2+c;
}
cout<<"Suma manjih je: "<<suma1<<endl;
cout<<"Suma vecih je: "<<suma2<<endl;
return 0;
}
Ispis na ekranu:
Riješeni zadaci Index
|