#17463: 請問我哪裡錯了


rexwu1104@gmail.com (黑雪公主 Black Lotus)


#include <iostream>
using namespace std;
int main() {
  long long int a, b, c=1, d=0;
  while (cin >> a >> b) {
    if (a>b) {
      while (c!=(b+1)) {
        if ((a%c==0)&&(b%c==0)) {
          d = c;
          c++;
        }
        else if (((a%c!=0)&&(b%c!=0))|((a%c!=0)&&(b%c==0))|((a%c==0)&&(b%c!=0))) {
          c++;
        }
      }
      cout << d << endl;
      c = 1;
    }
    else if (b>a) {
      while (c!=(a+1)) {
        if ((a%c==0)&&(b%c==0)) {
          d = c;
          c++;
        }
        else if (((a%c!=0)&&(b%c!=0))|((a%c!=0) &&(b%c==0))|((a%c==0)&&(b%c!=0))) {
          c++;
        }
      }   
      cout << d << endl;
      c = 1;
    }
  }
}
#17465: Re:請問我哪裡錯了


ufve0704 (爬 我爬 我爬爬爬 有排行榜這種東西就是要爬 爬過我上面的那...)


#include
using namespace std;
int main() {
  long long int a, b, c=1, d=0;
  while (cin >> a >> b) {
    if (a>b) {
      while (c!=(b+1)) {
        if ((a%c==0)&&(b%c==0)) {
          d = c;
          c++;
        }
        else if (((a%c!=0)&&(b%c!=0))|((a%c!=0)&&(b%c==0))|((a%c==0)&&(b%c!=0))) {
          c++;
        }
      }
      cout << d << endl;
      c = 1;
    }
    else if (b>a) {
      while (c!=(a+1)) {
        if ((a%c==0)&&(b%c==0)) {
          d = c;
          c++;
        }
        else if (((a%c!=0)&&(b%c!=0))|((a%c!=0) &&(b%c==0))|((a%c==0)&&(b%c!=0))) {
          c++;
        }
      }   
      cout << d << endl;
      c = 1;
    }
  }
}


c++有GCD函數歐!

#17467: Re:請問我哪裡錯了


rexwu1104@gmail.com (黑雪公主 Black Lotus)


#include
using namespace std;
int main() {
  long long int a, b, c=1, d=0;
  while (cin >> a >> b) {
    if (a>b) {
      while (c!=(b+1)) {
        if ((a%c==0)&&(b%c==0)) {
          d = c;
          c++;
        }
        else if (((a%c!=0)&&(b%c!=0))|((a%c!=0)&&(b%c==0))|((a%c==0)&&(b%c!=0))) {
          c++;
        }
      }
      cout << d << endl;
      c = 1;
    }
    else if (b>a) {
      while (c!=(a+1)) {
        if ((a%c==0)&&(b%c==0)) {
          d = c;
          c++;
        }
        else if (((a%c!=0)&&(b%c!=0))|((a%c!=0) &&(b%c==0))|((a%c==0)&&(b%c!=0))) {
          c++;
        }
      }   
      cout << d << endl;
      c = 1;
    }
  }
}


c++有GCD函數歐!

我們不能用老師沒教的


#17470: Re:請問我哪裡錯了


rexwu1104@gmail.com (黑雪公主 Black Lotus)


#include
using namespace std;
int main() {
  long long int a, b, c=1, d=0;
  while (cin >> a >> b) {
    if (a>b) {
      while (c!=(b+1)) {
        if ((a%c==0)&&(b%c==0)) {
          d = c;
          c++;
        }
        else if (((a%c!=0)&&(b%c!=0))|((a%c!=0)&&(b%c==0))|((a%c==0)&&(b%c!=0))) {
          c++;
        }
      }
      cout << d << endl;
      c = 1;
    }
    else if (b>a) {
      while (c!=(a+1)) {
        if ((a%c==0)&&(b%c==0)) {
          d = c;
          c++;
        }
        else if (((a%c!=0)&&(b%c!=0))|((a%c!=0) &&(b%c==0))|((a%c==0)&&(b%c!=0))) {
          c++;
        }
      }   
      cout << d << endl;
      c = 1;
    }
  }
}


c++有GCD函數歐!

重用就可以了