23.1.23020140. Generisati 2 različita cijela broja. Ako su oba parna podijeliti veći sa manjim brojem. Ako su oba neparna od većeg oduzeti manji broj. Inače sabrati ta dva broja.

Opis rješenja:

Listing programa:

//23020140
#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace std;

int main(){
	srand(time(NULL));
	
	int a=rand()%200,b=rand()%200;
	double rez=0;
	
	cout<<a<<" "<<b<<endl;
	
	if(a % 2 == 0 && b % 2 == 0){
		if(a > b){
			rez=a/b;
			cout<<"Rezultat je: "<<rez<<endl;
		}
		if(b > a){
			rez=b/a;
			cout<<"Rezultat je: "<<rez<<endl;
		}
		if(a == b){
			cout<<"Rezultat je: 1"<<endl;
		}
		return 0;
	}
	if(a % 2 != 0 && b % 2 != 0){
		if(a > b){
			rez=a-b;
			cout<<"Rezultat je: "<<rez<<endl;
		}
		if(b > a){
			rez=b-a;
			cout<<"Rezultat je: "<<b-a<<endl;
		}
		if(a == b){
			cout<<"Rezultat je: 0"<<endl;
		}
		return 0;
	}
	else{
		rez=a+b;
		cout<<"Rezultat je: "<<rez<<endl;
	}
	return 0;
}

Ispis na ekranu:

Riješeni zadaci    Index