1 条题解
-
0
C :
#include <stdio.h> int main() { int a, b, i; scanf("%d %d", &a, &b); for(i = a ; i >= 1; i --) { if(a % i == 0 && b % i == 0) { printf("%d\n", i); break; } } return 0; }
C++ :
#include<stdio.h> int main() { int m,n; int m_cup,n_cup,res; scanf("%d%d",&m,&n); if (m>0&&n>0) { m_cup=m; n_cup=n; res=m_cup%n_cup; while(res!=0) { m_cup=n_cup; n_cup=res; res=m_cup%n_cup; } printf("%d\n",n_cup); } }
- 1
信息
- ID
- 1767
- 时间
- 1000ms
- 内存
- 12MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者