/**********************************************************************************/
/* Problem: a054 "電話客服中心" from 板橋高中教學題 */
/* Language: CPP (770 Bytes) */
/* Result: WA(line:1) judge by this@ZeroJudge */
/* Author: yinz at 2013-04-03 19:59:02 */
/**********************************************************************************/
#include<iostream>
using namespace std;
int main()
{
int x;
while(cin>>x)
{
int a[9];
for(int i=1; i<=9; i++)
{
a[i]=x%10;
x/=10;
}
int sum=0;
for(int i=2; i<=9; i++)
{
sum+=a[i]*(i-1);
}
sum+=a[1];
switch(sum%10)
{
case 1:
cout<<"CIP"<<endl;
break;
case 2:
cout<<"DOQ"<<endl;
break;
case 3:
cout<<"ER"<<endl;
break;
case 4:
cout<<"FS"<<endl;
break;
case 5:
cout<<"GT"<<endl;
break;
case 6:
cout<<"HU"<<endl;
break;
case 7:
cout<<"JVX"<<endl;
break;
case 8:
cout<<"KLY"<<endl;
break;
case 9:
cout<<"AMW"<<endl;
break;
case 0:
cout<<"BNZ"<<endl;
break;
}
}
return 0;
}
----
WA (line:1)
答案不正確
您的答案為: HU (4) 正確答案為: FS (6)
---
以上
用範例測資試是沒有問題的, 而且也已經避開了c=10的問題,
是這樣籨line:1開始錯的話, 是小弟的sum本身有問題嗎?
求高人幫忙..
/**********************************************************************************/
/* Problem: a054 "電話客服中心" from 板橋高中教學題 */
/* Language: CPP (770 Bytes) */
/* Result: WA(line:1) judge by this@ZeroJudge */
/* Author: yinz at 2013-04-03 19:59:02 */
/**********************************************************************************/
#include
using namespace std;
int main()
{
int x;
while(cin>>x)
{
int a[9];
for(int i=1; i<=9; i++)
{
a[i]=x%10;
x/=10;
}
int sum=0;
for(int i=2; i<=9; i++)
{
sum+=a[i]*(i-1);
}
sum+=a[1];
switch(sum%10)
{
case 1:
cout<<"CIP"< break;
case 2:
cout<<"DOQ"< break;
case 3:
cout<<"ER"< break;
case 4:
cout<<"FS"< break;
case 5:
cout<<"GT"< break;
case 6:
cout<<"HU"< break;
case 7:
cout<<"JVX"< break;
case 8:
cout<<"KLY"< break;
case 9:
cout<<"AMW"< break;
case 0:
cout<<"BNZ"< break;
}
}
return 0;
}
----
WA (line:1)
答案不正確
您的答案為: HU (4) 正確答案為: FS (6)
---
以上
用範例測資試是沒有問題的, 而且也已經避開了c=10的問題,
是這樣籨line:1開始錯的話, 是小弟的sum本身有問題嗎?
求高人幫忙..
宣告 int a[9]; 位置是從0~8,並不是1~9
當i=9 就出錯了