Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
141482 吕毅心 最大公约数(函数) C++ Accepted 0 MS 272 KB 793 2025-12-25 18:58:28

Tests(10/10):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; void john(int a,int b){ if(a==b){ cout<<a; }else if(a>b){ for(int i=b;i>=1;i--){ if(a%i==0){ if(b%i==0){ cout<<i; break; } } } }else{ for(int i=a;i>=1;i--){ if(a%i==0){ if(b%i==0){ cout<<i; break; } } } } } int main(){ int j,k; cin>>j>>k; john(j,k); return 0; }