[Coursera]算法基础_Week9_考试_Q2

来源:互联网 发布:c语言经典编程题pdf 编辑:程序博客网 时间:2024/05/17 08:35
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <set>#include <string.h>using namespace std;//int map[1025][1025];int ans[1025][1025];struct Point {int x;int y;int cl;Point(int x_,int y_,int cl_):x(x_),y(y_),cl(cl_){}};int F(int m, int n) {if (n > m) {int temp = m;m = n;n = temp;}if (m%n == 0)return n;else {return F(m%n, n);}}int main(){int M, N;while(cin >> M >> N) {cout << F(M, N) << endl;}return 0;}

0 0
原创粉丝点击