一片紫光

P1055 [NOIP2008 普及组] ISBN 号码

huanglihuan @ 2023-08-23 14:22:19

#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

int a,b,c;
char t;

int main()
{
    scanf ("%d-%d-%d-%c",a,b,c,t);
    int d = b / 100;
    int e = b / 10 % 10;
    int f = b % 10;
    int g = c / 10000;
    int h = c / 1000 % 10;
    int i = c / 100 % 10;
    int j = c / 10 % 10;
    int k = c % 10;
    int l = d * 2;
    int m = e * 3;
    int n = f * 4;
    int o = g * 5;
    int p = h * 6;
    int q = i * 7;
    int r = j * 8;
    int s = k * 9;
    int ans = a + l + m + n + o + p + q + r + s;
    int sum = ans % 11;
    if (sum == 10)
    printf ("%d-%d-%d-x",a,b,c);
    else
    printf ("%d-%d-%d-%d",a,b,c,sum);
    return 0;
}

by WYZ20030051 @ 2023-08-23 14:24:44

scanf不加取地址符?


by Ruiqun2009 @ 2023-08-23 14:24:45

scanf ("%d-%d-%d-%c",a,b,c,t);

->

scanf ("%d-%d-%d-%c",&a,&b,&c,&t);

by zsh_haha @ 2023-08-23 14:24:52

@huanglihuan 大哥,你scanf加取地址符了吗


by wwwidk1234 @ 2023-08-23 14:25:13

scanf ("%d-%d-%d-%c",a,b,c,t);


by so_find_skind @ 2023-08-23 14:25:47

@zsh_haha

你还想指望lz知道啥是取地址符是吗。。。


by huanglihuan @ 2023-08-23 14:34:15

感谢各位大佬 (刚睡醒,脑子有些昏)


by huanglihuan @ 2023-08-23 14:36:07

不过只有40分


by MYiFR @ 2023-08-23 14:42:54

测样例了吗


by MYiFR @ 2023-08-23 14:45:04

题目要求输出大写字母 X,你输出的是小写


|