Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main () {
- int a,b,z,i,r,q,m,s,j,k,x;
- do{
- do{
- system ("cls");
- printf("Inserisci primo numero\n");
- printf("\n");
- scanf("%d",&a);
- printf("\n");
- k=a;
- printf("Inserisci secondo numero\n");
- printf("\n");
- scanf("%d",&b);
- printf("\n");
- j=b;
- if (a<=0|| b<=0){
- printf ("Errore:i numeri devono essere entrambi maggiori di 0\n");
- printf ("\n");
- system("PAUSE");
- }
- }while (a<=0 || b<=0);
- m=(a<b?b:a);
- z=1;
- i=2;
- do{
- do{
- if(!(r=a%i)) a/=i;
- if(!(q=b%i)) b/=i;
- if (!(s=r*q)) z*=i;
- }while(!s);
- if(i<m) i++;
- }while(i<m);
- if((z==k && i==j) || (z==j && i==k) ){z=k*j;
- }
- if (k==j){printf ("m.c.m=%d\n",k);
- }else{
- printf("m.c.m.=%d \n",z);
- }
- printf("\n");
- printf("Vuoi continuare? 1=si 0=no\n");
- printf("\n");
- scanf("%d",&x);
- printf("\n");
- if (x<0 || x >1)
- do{printf("Errore nei dati\n");
- printf("\n");
- printf("Vuoi continuare? 1=si 0=no\n");
- printf("\n");
- scanf("%d",&x);
- system ("cls");
- }while (x>1 || x<0);
- if (x==0) {
- exit (1);
- }
- }while (x==1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement