23.1.23020058. Generisati 3 dvocifrena broja. Neparnim dodati 5, a od parnih oduzeti 2.

Opis rješenja:

Listing programa:

//23020058
#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;
	
	cout<<a<<" "<<b<<" "<<c<<endl;
	
	if(a % 2 != 0){
		a=a+5;
		cout<<a<<endl;
	}
		else{
			a=a-2;
			cout<<a<<endl;
		}
	if(b % 2 != 0){
		b=b+5;
		cout<<b<<endl;
	}
		else{
			b=b-2;
			cout<<b<<endl;
		}
	if(c % 2 != 0){
		c=c+5;
		cout<<c<<endl;
	}
		else{
			c=c-2;
			cout<<c<<endl;
		}
	return 0;
	}

Ispis na ekranu:

Riješeni zadaci    Index