题解

281 条题解

  • 0
    @ 2013-11-09 20:03:53

    #include <stdio.h>

    char a[15];

    int main()
    {
    int i , ct = 1 , sum = 0;
    char ch;

    scanf("%s" , a);

    for(i = 0 ; i < 11 ; i ++ )
    {
    if(a[i] != '-')
    {
    sum += (a[i] - '0') * ct;
    sum %= 11;
    ct ++ ;
    }
    }
    ch = sum < 10 ? sum + '0' : 'X';
    if(a[12] == ch)
    {
    printf("Right\n");
    }
    else
    {
    a[12] = ch;
    printf("%s\n" , a);
    }
    return 0;
    }

  • 0
    @ 2013-09-07 23:41:59

    一次过
    #include <iostream>
    #include <cstdlib>
    #include <math.h>
    #include <string>
    using namespace std;
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */
    string a;
    string isbn;
    string test,test2;
    int sum,check,i,j,k,len,b;
    int main(int argc, char *argv[]) {
    cin>>a;
    b=0;
    len=a.length();
    for(i=0;i<=len-3;i++){
    if(a[i]!='-'){
    b++;
    test=a[i];
    sum+=atoi(test.c_str())*b;
    }
    }
    if(a[len-1]=='X'){
    check=10;
    }
    else{
    test2=a[len-1];
    check=atoi(test2.c_str());
    }
    if(sum%11==check){
    cout<<"Right"<<endl;
    }
    else{
    for(i=0;i<=len-2;i++){
    cout<<a[i];
    }
    if(sum%11==10){
    cout<<"X"<<endl;
    }
    else{
    cout<<sum%11<<endl;
    }
    }
    }

  • 0
    @ 2013-08-29 15:29:30

    秒过100分!!!!!!
    var s,g:string;
    a:array[0..100000]of longint;
    max,man,i,j,l,x,y:longint;
    begin
    readln(s);
    i:=1;
    max:=length(s);
    man:=ord(s[max])-48;
    for l:=1 to max-2 do
    if s[l]<>'-' then begin a[i]:=ord(s[l])-48;x:=x+(a[i]*i);inc(i); end;
    y:=x mod 11;
    if y=man then begin writeln('Right');halt;end else
    if (y<>man) and (y<10) then
    begin for i:=1 to max-1 do
    write(s[i]);
    writeln(y);
    halt;
    end;
    if y>=10 then
    begin
    if man=40 then
    begin
    writeln('Right');
    halt;
    end;
    for i:=1 to max-1 do
    write(s[i]);
    writeln('X');
    halt;
    end;
    end.

  • 0
    @ 2013-08-11 17:40:15

    吼吼~~看看哥的奇葩题解~*(貌似是个渣。。。)*
    var a:string;s:longint;
    begin
    readln(a);
    s:=((ord(a[1])-48)*1+(ord(a[3])-48)*2+(ord(a[4])-48)*3+(ord(a[5])-48)*4+(ord(a[7])-48)*5+(ord(a[8])-48)*6+(ord(a[9])-48)*7+(ord(a[10])-48)*8+(ord(a[11])-48)*9) mod 11;
    if s=10 then s:=ord('X')-48;if ord(a[13])-48=s then writeln('Right') else writeln(copy(a,1,12)+chr(s+48));
    end.

  • 0
    @ 2013-07-27 16:43:35

    #include<stdio.h>
    int main()
    {
    int a,b,c,d,e,f,j,k,m,n;
    scanf("%d-%d%d%d-%d%d%d%d%d-%d",&a,&b,&c,&d,&e,&f,&j,&k,&m,&n);
    {
    int s=0,t;
    s=a*1+b*2+c*3+d*4+e*5+f*6+j*7+k*8+m*9;
    if(n=s%11)

    printf("Right");
    else
    {
    t=s%11;
    printf("%d-%d%d%d-%d%d%d%d%d-%d",a,b,c,d,e,f,j,k,m,t);

    }

    }
    return 0;
    }

  • 0
    @ 2013-07-22 18:08:03

    五分钟了还是Judging

  • 0
    @ 2013-03-20 22:39:23
  • 0
    @ 2012-11-06 18:43:00

    貌似so简单

  • 0
    @ 2012-10-31 18:00:12

    #include

    using namespace std;

    int main ( )

    {

    string ISBN;

    cin >> ISBN;

    int sum = 0;

    char identifier;

    sum += ( ISBN[0] - '0' ) * 1;

    sum += ( ISBN[2] - '0' ) * 2;

    sum += ( ISBN[3] - '0' ) * 3;

    sum += ( ISBN[4] - '0' ) * 4;

    sum += ( ISBN[6] - '0' ) * 5;

    sum += ( ISBN[7] - '0' ) * 6;

    sum += ( ISBN[8] - '0' ) * 7;

    sum += ( ISBN[9] - '0' ) * 8;

    sum += ( ISBN[10] - '0' ) * 9;

    sum %= 11; 

    identifier = sum + '0';

    if ( ( identifier - '0' ) == 10 )//当mod11=10时还要判断识别码正确的情况,我就是忽略了这一步导致一直是50分。

    {

    if ( ISBN[12] == 'X' ) 

    {

    cout

  • 0
    @ 2012-10-28 22:45:08

    AC50纪念,水题去死吧!

  • 0
    @ 2012-11-08 22:15:20

    这题真心沾了我一身水。。。。。。。。。。。。。。

    点这里查看程序源码+详细题解

  • 0
    @ 2012-10-22 20:33:30

    首先自定义一个字符转成数字的函数v(c);用字符串接收输入后,利用自定义函数将串中的第1,3,4,5,7,8,9,10,11位置的字符对应的数字乘以相应数字后相加(一个语句足已),然后取模得到第13位字符对应的数字,设为t,与输入串中的第13位字符对照,相同则输入'Right',否则将输入串的前12位+t对应的字符输出即可。

  • 0
    @ 2012-10-16 22:39:07

    var

    a:array[1..16] of longint;

    n:string; b,p:longint;

    begin

    readln(n); for c:=1 to 13 do a[c]:=-1;

    for c:=1 to 13 do

    if n[c]'-' then a[c]:=ord(n[c])-ord('0');

    for c:=1 to 11 do

    if a[c]-1 then begin p:=p+1;d:=a[c]*p+1; end;

    b:=b mod 11;

    if a[13]=b then write('Right') else begin

    n[13]:=chr(b+ord('0'));

    write(n);

    end;

    end.

    为什么错?

  • 0
    @ 2012-10-15 20:13:42

    我的代码

  • 0
    @ 2012-09-26 22:52:03

    var a:string; i,x:integer;

    begin

    read(a);

    delete(a,2,1);

    delete(a,5,1);

    delete(a,10,1);

    for i:=1 to 9 do

    x:=x+i*(ord(a[i])-48);

    x:=x mod 11;

    if a[10]'x'

    then

    begin

    if x=(ord(a[10])-48)

    then write('right')

    else

    begin

    insert('-',a,2); insert('-',a,6);insert('-',a,12);if x=10 then a[13]:='x' else a[13]:=char((x mod 11)+48);

    write(a);

    end;

    end

    else

    if x=10

    then write('right')

    else

    begin

    insert('-',a,2); insert('-',a,6);insert('-',a,12);if x=10 then a[13]:='x' else a[13]:=char((x mod 11)+48);

    write(a);

    end;

    end.

  • 0
    @ 2012-07-28 10:01:14

    Program isbn;

    var s,sss:string;

    s1,s2,s3,s4,s5,s6,s7,s8,s9,ss:string;

    a:array[1..10] of integer;

    t:integer;

    n:integer;

    code:integer;

    procedure init;

    begin

    read(s);

    end;

    procedure main;

    var i:integer;

    begin

    s1:=s[1]; s2:=s[3]; s3:=s[4]; s4:=s[5]; s5:=s[7];

    s6:=s[8]; s7:=s[9]; s8:=s[10]; s9:=s[11]; ss:=s[13];

    val(s1,a[1],code);

    val(s2,a[2],code);

    val(s3,a[3],code);

    val(s4,a[4],code);

    val(s5,a[5],code);

    val(s6,a[6],code);

    val(s7,a[7],code);

    val(s8,a[8],code);

    val(s9,a[9],code);

    val(ss,a[10],code);

    for i:=1 to 9 do

    t:=t+a[i]*i;

    t:=t mod 11;

    if t=10 then sss:='X';

    if (t=10) and (s[13]='X') then write('Right')

    else

    if (t10) and (a[10]=t) then write('Right')

    else

    begin

    delete(s,13,1);

    if t10 then

    begin

    str(t,ss);

    insert(ss,s,13);

    write(s);

    end

    else

    begin

    insert(sss,s,13);

    write(s);

    end;

    end;

    end;

    begin

    init;

    main;

    end.

  • 0
    @ 2010-07-24 16:29:14

    program isbn;

    var

    a:array[1..13] of char;

    i,c,k:integer;

    b:char;

    begin

    for i:=1 to 13 do read(a[i]);

    k:=1;

    for i:=1 to 11 do

    if ord(a[i])ord('-')

    then

    begin

    c:=(ord(a[i])-48)*k+c;

    k:=k+1;

    end;

    c:=c mod 11;

    if c=10 then b:='x'

    else

    b:=chr(c+48);

    if b=a[13] then write('Right')

    else

    begin

    a[13]:=b;

    for i:=1 to 13 do write(a[i]);

    end;

    end.

  • 0
    @ 2010-07-13 21:02:40

    #include

    int main(void){long a, b, c, d, result = -1, cnt; if ((scanf("%ld-%ld-%ld-%ld", &a, &b, &c, &d)) == 4) result = d; cnt = ((a*1) + ((b/100)*2 + (b%100/10)*3 + (b%100%10)*4) +((c/10000)*5 + (c%10000/1000)*6 + (c%10000%1000/100)*7 +(c%10000%1000%100/10)*8 + (c%10000%1000%100%10)*9)) % 11; if ((cnt == result) || (cnt == 10 && result == -1)) printf("Right\n"); else printf("%ld-%ld-%ld-%c\n", a, b, c, cnt == 10 ? 'X' : cnt+'0'); return 0;}

    AC!

  • 0
    @ 2010-03-07 13:45:53

    var

    a:array[1..13] of char; s,i,j:integer;

    b:array[1..10] of integer;

    begin

    j:=1; s:=0;

    for i:=1 to 12 do

    begin

    read(a[i]);

    if (a[i]>='0') and (a[i]

  • 0
    @ 2010-03-02 13:42:42

    program ISBN;

    var s,ans,ch:string;

      i,j,an:longint;

    begin

    read(s);

    j:=1;

    i:=1;

    while j='0') and (s[i]

信息

ID
1484
难度
5
分类
字符串 点击显示
标签
递交数
14462
已通过
4955
通过率
34%
被复制
33
上传者