Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
94786 | 杜洛雨泽 | 最大公约数 | C++ | Wrong Answer | 1 MS | 268 KB | 322 | 2024-10-26 13:28:16 |
#include <bits/stdc++.h> using namespace std; int main (){ int a,b,f; cout<<"请输入第一个正整数:"; cin>>a; cout<<"请输入第二个正整数:"; cin>>b; f=(a<b)?a:b; while(f>0){ if(a%f==0&&b%f==0){ break; } f--; } cout<<"最大公约数为:"<<f<<endl; return 0; }
------Input------
234 396
------Answer-----
18
------Your output-----
请输入第一个正整数:请输入第二个正整数:最大公约数为:18