#include<iostream> using namespace std; int first(int); int main(){ int n,check; int eng[26]={10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33}; while(cin>>n){ int sum=0; check=10-(n%10); n/=10; for(int i=1;i<=8;i++){ sum+=((n%10)*i); n/=10; } for(int i=0;i<25;i++){ if((sum+first(eng[i]))%10==check) cout<<(char)(i+65); } cout<<'\n'; } return 0; } int first(int n){ return n/10+(n%10)*9; }
您的答案為: JVX 正確答案為: KLY
想請教各位大大,程式哪裡出問題了?測試執行時沒問題的......
#include using namespace std; int first(int); int main(){ int n,check; int eng[26]={10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33}; while(cin>>n){ int sum=0; check=10-(n%10); n/=10; for(int i=1;i<=8;i++){ sum+=((n%10)*i); n/=10; } for(int i=0;i<25;i++){ if((sum+first(eng[i]))%10==check) cout<<(char)(i+65); } cout<<'\n'; } return 0; } int first(int n){ return n/10+(n%10)*9; }
您的答案為: JVX 正確答案為: KLY
想請教各位大大,程式哪裡出問題了?測試執行時沒問題的......
你可以看看如果身分證的檢查嗎如果是 $0$ 的時候會發生什麼事
這樣你的 $check$ 就會是 $10$
所以這樣那行就不會有輸出
#include using namespace std; int first(int); int main(){ int n,check; int eng[26]={10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33}; while(cin>>n){ int sum=0; check=10-(n%10); n/=10; for(int i=1;i<=8;i++){ sum+=((n%10)*i); n/=10; } for(int i=0;i<25;i++){ if((sum+first(eng[i]))%10==check) cout<<(char)(i+65); } cout<<'\n'; } return 0; } int first(int n){ return n/10+(n%10)*9; }
您的答案為: JVX 正確答案為: KLY
想請教各位大大,程式哪裡出問題了?測試執行時沒問題的......
你可以看看如果身分證的檢查嗎如果是 $0$ 的時候會發生什麼事
這樣你的 $check$ 就會是 $10$
所以這樣那行就不會有輸出
原來如此,謝謝!
#include using namespace std; int first(int); int main(){ int n,check; int eng[26]={10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33}; while(cin>>n){ int sum=0; check=10-(n%10); n/=10; for(int i=1;i<=8;i++){ sum+=((n%10)*i); n/=10; } for(int i=0;i<25;i++){ if((sum+first(eng[i]))%10==check) cout<<(char)(i+65); } cout<<'\n'; } return 0; } int first(int n){ return n/10+(n%10)*9; }
您的答案為: JVX 正確答案為: KLY
想請教各位大大,程式哪裡出問題了?測試執行時沒問題的......
你可以看看如果身分證的檢查嗎如果是 $0$ 的時候會發生什麼事
這樣你的 $check$ 就會是 $10$
所以這樣那行就不會有輸出
抱歉,我想請教一下,我也是遇到同樣的問題
我把檢查碼為 $0$ 的跳過了,但還是WA(line:2)
程式碼如下:
#include <iostream>
using namespace std;
const int dict[26] = {10, 11, 12, 13, 14, 15, 16,
17, 34, 18, 19, 20, 21, 22,
35, 23, 24, 25, 26, 27, 28,
29, 32, 30, 31, 33};
int main(){
ios::sync_with_stdio(false); cin.tie(0);
bool flag = false;
string str;
while(cin >> str){
if(flag)
cout << '\n';
flag = false;
if(str[8] != '0'){
int s = 0;
for(int i = 0 ; i < 8 ; i++){
s += (str[i] - '0') * (8 - i);
}
for(int i = 0 ; i < 26 ; i++){
int m = (s + dict[i] / 10 + (dict[i] % 10) * 9) % 10;
if(str[8] - '0' == 10 - m){
flag = true;
cout << char(i + 'A');
}
}
}
}
return 0;
}