zltzlt 发表于 2020-1-18 21:59:04

洛谷题目 P1055

// https://www.luogu.com.cn/problem/P1055

#include <iostream>
using namespace std;

int main()
{
    char s, mod = "0123456789X";
    int i, j = 1, a = 0;
    for (i = 0; i < 13; i++)
    {
      cin >> s;
      if ((s != '-') && i != 12)
      {
            if (s != 'X')
                a += (s - '0') * j;
            else
                a += 11 * j;
            j++;
      }
    }
    if ((a % 11) == (s - '0'))
      cout << "Right";
    else if ((s == 'X') && ((a % 11) == 10))
    {
      cout << "Right";
    }
    else
    {
      for (i = 0; i < 12; i++)
      {
            cout << s;
      }
      cout << mod;
    }
    return 0;
}
页: [1]
查看完整版本: 洛谷题目 P1055