2019-10-29 13:14:29 +00:00
|
|
|
#include <stdio.h>
|
2019-10-29 13:20:21 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
2019-10-29 13:24:52 +00:00
|
|
|
#include <string.h>
|
2019-11-10 14:58:03 +00:00
|
|
|
long long int nsd(long long int,long long int);
|
2019-10-29 13:20:21 +00:00
|
|
|
|
2019-11-10 14:58:03 +00:00
|
|
|
long long int nsd(long long int cislo1,long long int cislo2){
|
|
|
|
while (cislo1 != cislo2){
|
|
|
|
if (cislo1 > cislo2){
|
|
|
|
cislo1 -= cislo2;
|
|
|
|
} else{
|
|
|
|
cislo2 -= cislo1;
|
|
|
|
}
|
2019-10-29 13:20:21 +00:00
|
|
|
}
|
2019-11-10 14:58:03 +00:00
|
|
|
return cislo1;
|
|
|
|
}
|
|
|
|
int main() {
|
|
|
|
freopen("vstup.txt","r",stdin);
|
|
|
|
char* prvy_vstup = malloc(100* sizeof(char));
|
|
|
|
char* druhy_vstup = malloc(100* sizeof(char));
|
2019-10-29 13:37:38 +00:00
|
|
|
|
2019-11-10 14:58:03 +00:00
|
|
|
fgets(prvy_vstup,100,stdin);
|
|
|
|
strtok(prvy_vstup,"\n");
|
|
|
|
if (!isdigit(*prvy_vstup)){
|
|
|
|
printf("%s je neplatny zapis.\n",prvy_vstup);
|
|
|
|
goto koniec;
|
|
|
|
} else{
|
|
|
|
printf("Nacitane %llu\n",strtoll(prvy_vstup,NULL,10));
|
|
|
|
}
|
2019-10-29 13:46:53 +00:00
|
|
|
|
2019-11-10 14:58:03 +00:00
|
|
|
while((fgets(druhy_vstup,100,stdin))){
|
|
|
|
strtok(druhy_vstup,"\n");
|
2019-10-29 13:46:53 +00:00
|
|
|
|
2019-11-10 14:58:03 +00:00
|
|
|
if (!isdigit(*druhy_vstup)){
|
|
|
|
printf("%s je neplatny zapis.\n",druhy_vstup);
|
|
|
|
goto koniec;
|
|
|
|
} else{
|
|
|
|
long long int vysledok = nsd(strtoll(prvy_vstup,NULL,10),strtoll(druhy_vstup,NULL,10));
|
|
|
|
printf("Nacitane %llu\n",strtoll(druhy_vstup,NULL,10));
|
|
|
|
printf("Najvacsi spolocny delitel cisel %llu a %llu je %llu\n",strtoll(prvy_vstup,NULL,10),strtoll(druhy_vstup,NULL,10),vysledok);
|
2019-10-29 13:46:53 +00:00
|
|
|
|
|
|
|
}
|
2019-10-29 13:37:38 +00:00
|
|
|
|
2019-10-29 13:14:29 +00:00
|
|
|
}
|
2019-11-10 14:58:03 +00:00
|
|
|
koniec:
|
|
|
|
free(prvy_vstup);
|
|
|
|
free(druhy_vstup);
|
2019-10-29 13:14:29 +00:00
|
|
|
}
|