diff options
| author | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
| commit | 4022e5c95210631e4aceb08eaf9d9071aa5aefc4 (patch) | |
| tree | a5922559836e45fb3459a3d070367912e1035b1a /tests/sysy_lvX/gcd.sy | |
| download | rcc-master.tar.gz rcc-master.tar.xz | |
Diffstat (limited to 'tests/sysy_lvX/gcd.sy')
| -rw-r--r-- | tests/sysy_lvX/gcd.sy | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/sysy_lvX/gcd.sy b/tests/sysy_lvX/gcd.sy new file mode 100644 index 0000000..881c52d --- /dev/null +++ b/tests/sysy_lvX/gcd.sy @@ -0,0 +1,42 @@ +int gcd1(int m,int n) +{ + int t,r; + if (m<n) + { + t=m; + m=n; + n=t; + } + + while((m%n)!=0) + { + r=m%n; + m=n; + n=r; + } + + return n; +} + +int gcd2(int x, int y) +{ if (y!=0) + return gcd2(y, x%y); + else + return x; +} +int main(){ + int num=getint(); + while(num>0){ + int m=getint(); + int n=getint(); + int t1=gcd1(m,n); + int t2=gcd2(m,n); + putint(t1); + putch(10); + putint(t2); + putch(10); + num=num-1; + } + + return 0; +}
\ No newline at end of file |
