| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
高手帮忙! 总是WA! 谢谢!#include <iostream>
#include <string>
using namespace std;
void main()
{
string ID;
int a, i, j,c,d,n, product;
int factors1[ 7 ] = {9, 7, 3, 9, 7, 3, 9}, factors2[ 6 ] = { 7, 3, 9, 7, 3, 9 };
cin >> n;
for ( int e = 1; e <= n; e++ )
{
cin >> ID;
cout << "Scenario #" << e << ":" << endl;
a = ID.length();
if ( a == 7)
{
for ( i = 0; i < a; i++ )
{
if ( ID[ i ] == 63 )
{
c = i;
continue;
}
product += ( ID[ i ] - 48) * factors1[ i ];
d = product;
}
for ( j = 0; j <= 9; j++ )
{
product = d;
product += j * factors1[ c ];
if ( product % 10 == 0 )
{
ID [ c ] = j + 48;
break;
}
}
for ( i = 0; i < a; i++ )//h--i
cout << ID[ i ];
cout << endl << endl;
continue;
}
else
{
for ( i = 0; i < a; i++ )
{
if ( ID[ i ] == 63 )
{
c = i;
continue;
}
product += ( ID[ i ] - 48 ) * factors2[ i ];
d = product;
}
for ( j = 0; j <= 9; j++ )
{
product = d;
product += j * factors2[ c ];
if ( product % 10 == 0)
{
ID[ c ] = j + 48;
break;
}
}
for ( i = 0; i < a; i++ )
cout << ID[ i ];
cout << endl << endl;
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator