P8044
查看原帖
P8044
513997
HNOIRPplusplus楼主2022/2/6 14:52

这个题要是能有下载数据的话我也不会来问了
我感觉我和大部分题解思路都不太一样啊。。。

#include <iostream>

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  bool aa = 0, bb = 0;
  if(a.length() > b.length()) {
    aa = 1;
    cout << a.substr(0, a.length() - b.length());
    a.erase(0, a.length() - b.length());
  }
  if(b.length() > a.length()) {
    bb = 1;
    cout << b.substr(0, b.length() - a.length());
    b.erase(0, b.length() - a.length());
  }
  for(int i = 0; i < a.length(); i++) {
    if(a[i] >= b[i]) {
      aa = 1;
    }
    if(b[i] >= a[i]) {
      bb = 1;
    }
  }
  int c = 0;
  for(int i = 0; aa && i < a.length(); i++) {
    if(a[i] >= b[i]) {
      c = c * 10 + a[i] - '0';
    }
  }
  if(aa) {
    cout << c;
  } else {
    cout << "YODA";
  }
  cout << '\n';
  c = 0;
  for(int i = 0; bb && i < b.length(); i++) {
    if(b[i] >= a[i]) {
      c = c * 10 + b[i] - '0';
    }
  }
  if(bb) {
    cout << c;
  } else {
    cout << "YODA";
  }
  return 0;
}
2022/2/6 14:52
加载中...