C求最大公约数 求帮忙分析下错误
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/07/11 18:15:15
C求最大公约数 求帮忙分析下错误
int a,b;int c,temp;
scanf("d%,d%",&a,&b);
if(a
int a,b;int c,temp;
scanf("d%,d%",&a,&b);
if(a
![C求最大公约数 求帮忙分析下错误](/uploads/image/z/18559745-17-5.jpg?t=C%E6%B1%82%E6%9C%80%E5%A4%A7%E5%85%AC%E7%BA%A6%E6%95%B0+%E6%B1%82%E5%B8%AE%E5%BF%99%E5%88%86%E6%9E%90%E4%B8%8B%E9%94%99%E8%AF%AF)
#include <stdio.h>
#include <string.h>
void main()
{
int a,b;
int c,temp;
scanf("%d,%d",&a,&b); //%d 不是 d%
if(a<b){c=a;a=b;b=c;}
while(1)
{temp=b;b= a%b;a=b;
if(a%b==0)
break;
}
printf("%d",a); //%d 不是 d%
}
#include <string.h>
void main()
{
int a,b;
int c,temp;
scanf("%d,%d",&a,&b); //%d 不是 d%
if(a<b){c=a;a=b;b=c;}
while(1)
{temp=b;b= a%b;a=b;
if(a%b==0)
break;
}
printf("%d",a); //%d 不是 d%
}