czx_27 @ 2021-11-18 12:26:00
#include <stdio.h>
main()
{ int len,i,sum=0,k=1,h;
char a[14];
gets(a);
len=strlen(a);
for(i=0;i<len-1;i++)
if(a[i]!='-')
{sum+=(a[i]-'0')*k;
k++;
}
h=sum%11;
if(h==10)
{
if(a[12]=='X')
printf("Right\n");
else(a[12]>='0'&&a[12]<='9')
{
for(i=0;i<len-1;i++)
printf("%c",a[i]);
printf("X");
}
}
else
{
if((a[12]-'0')==(h))
printf("Right");
else
{
for(i=0;i<len-1;i++)
printf("%c",a[i]);
printf("%d",h);
}
}
}
by Fish9块1 @ 2021-11-18 12:42:59
奇妙的码风增加了
by Hilte @ 2021-11-18 13:04:50
+1
by czx_27 @ 2021-11-21 15:12:22
小白哈哈见谅,正确一点的码风是啥求大佬指点
by zhangqingy @ 2021-11-22 17:33:55
这个应该能对吧,是c++
#include<iostream>
using namespace std;
int main()
{
char s[14];
int j;
for (j = 0; j < 13; j++)
cin >> s[j];
int m = 1, n, f = 0;
int sum = 0;
for (j = 0; j < 11; j++)
{
if (s[j] != '-')
{
sum = sum + m * int(s[j] - '0');
m++;
}
}
n = sum % 11;
char c;
if (n == 10) c = 'X';
else c = n + '0';
if (c==s[12]) cout << "Right";
else
{
s[12] = c;
for (j = 0; j < 13; j++)
cout << s[j];
}
return 0;
}
by zhangqingy @ 2021-11-22 17:35:12
@czx_27
代码风格,是每写一行tab一下,遇到{ }应该在tab 一下
by czx_27 @ 2021-11-22 20:28:29
@zhangqingy O(∩_∩)O谢谢