zyz202412904240 @ 2024-09-24 20:26:25
#include <stdio.h>
int main()
{
char n2,n3,n4,n5,n6,n7,n8,n9,n10,n11;
int n1;
scanf("%c-%c%c%c-%c%c%c%c%c-%d",&n2,&n3,&n4,&n5,&n6,&n7,&n8,&n9,&n10,&n1);
int sum = (n2-48)*1 + (n3-48)*2 + (n4-48)*3 + (n5-48)*4 + (n6-48)*5 + (n7-48)*6 + (n8-48)*7 + (n9-48)*8 + (n10-48)*9;
int n = sum % 11;
if(n == 10)
{
if(n1 == 'X')
{
printf("Right\n");
} else
{
printf("%c-%c%c%c-%c%c%c%c%c-%d\n",n2,n3,n4,n5,n6,n7,n8,n9,n10,'X');
}
}
else
{
if(n1 == n)
{
printf("Right\n");
} else
{
printf("%c-%c%c%c-%c%c%c%c%c-%d\n",n2,n3,n4,n5,n6,n7,n8,n9,n10,n);
}
}
return 0;
}
by zjr2014 @ 2024-09-24 20:46:08
c++
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f,g,h,i,j;
char jc;
int main(){
scanf("%1d-%1d%1d%1d-%1d%1d%1d%1d%1d-%c",&a,&b,&c,&d,&e,&f,&g,&h,&i,&jc);
if(jc=='X'){
j=10;
}
else{
j=jc-'0';
}
if((a+b*2+c*3+d*4+e*5+f*6+g*7+h*8+i*9)%11==j){
cout<<"Right";
}
else{
if((a+b*2+c*3+d*4+e*5+f*6+g*7+h*8+i*9)%11==10){
cout<<a<<"-"<<b<<c<<d<<"-"<<e<<f<<g<<h<<i<<"-"<<'X';
}
else{
cout<<a<<"-"<<b<<c<<d<<"-"<<e<<f<<g<<h<<i<<"-"<<(a+b*2+c*3+d*4+e*5+f*6+g*7+h*8+i*9)%11;
}
}
return 0;
}
by zjr2014 @ 2024-09-24 20:46:29
@zyz202412904240
by zyz202412904240 @ 2024-09-24 20:49:19
@zjr2014 感谢,但还没学c++呢,看不懂。。
by zjr2014 @ 2024-09-25 08:45:26
@zyz202412904240 调出来了
#include <stdio.h>
int main()
{
char n2,n3,n4,n5,n6,n7,n8,n9,n10,n11;
char n1;
scanf("%c-%c%c%c-%c%c%c%c%c-%c",&n2,&n3,&n4,&n5,&n6,&n7,&n8,&n9,&n10,&n1);
int sum = (n2-48)*1 + (n3-48)*2 + (n4-48)*3 + (n5-48)*4 + (n6-48)*5 + (n7-48)*6 + (n8-48)*7 + (n9-48)*8 + (n10-48)*9;
int n = sum % 11;
if(n == 10)
{
if(n1 == 'X')
{
printf("Right\n");
} else
{
printf("%c-%c%c%c-%c%c%c%c%c-%c\n",n2,n3,n4,n5,n6,n7,n8,n9,n10,'X');
}
}
else
{
if(n1-48 == n)
{
printf("Right\n");
} else
{
printf("%c-%c%c%c-%c%c%c%c%c-%d\n",n2,n3,n4,n5,n6,n7,n8,n9,n10,n);
}
}
return 0;
}
by zyz202412904240 @ 2024-09-25 09:18:26
@zjr2014 谢谢大佬,关注了