Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int broj;
- scanf("%d", &broj);
- int tmp = broj;
- int broj_na_cifri = 0;
- int paren_broj = 0;
- int neparen_broj = 0;
- while(tmp > 0) {
- int cifra = tmp % 10;
- tmp /= 10;
- if(cifra % 2 == 0) {
- paren_broj = (paren_broj * 10) + cifra;
- }
- else {
- neparen_broj = (neparen_broj * 10) + cifra;
- }
- broj_na_cifri++;
- }
- if(broj_na_cifri % 2 == 1) {
- printf("GRESKA\n");
- return 0;
- }
- int paren = 0;
- int neparen = 0;
- tmp = paren_broj;
- while(tmp > 0) {
- int cifra = tmp % 10;
- tmp /= 10;
- paren = (paren * 10) + cifra;
- }
- tmp = neparen_broj;
- while(tmp > 0) {
- int cifra = tmp % 10;
- tmp /= 10;
- neparen = (neparen * 10) + cifra;
- }
- int proizvod = paren * neparen;
- int resultat = 0;
- tmp = proizvod;
- while(tmp > 0) {
- int cifra = tmp % 10;
- tmp /= 10;
- resultat = (resultat * 10) + cifra;
- }
- printf("%d\n", resultat);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment