50分求调

P1055 [NOIP2008 普及组] ISBN 号码

Retoayd @ 2023-10-14 19:27:26

#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
  cin>>a;
  int ans=0,l=1;
  for(int i=0; i<12-1; i++)
  {
    if (a[i]=='-') continue;
    else
    {
      ans+=(a[i]-'0')*l;
      l++;
    }
  }
  ans%=11;
  if(ans==a[12]-'0')
  {
    cout<<"Right";
  }
  else
  {
    for(int i=0; i<12; i++)
    {
      cout<<a[i];
    }
    cout<<ans;
  }
  return 0;
}

by cmpt_xiaoxiao @ 2023-10-14 19:38:28

X?


by wo_shi_zhong_guo_ren @ 2023-10-17 20:30:30

如果mod11为十或十以上,要改为X


|