Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

高手能不能帮我看一下啊?我实在是想不出错在那儿了?

Posted by ypy at 2009-04-08 16:10:34 on Problem 2498
#include <iostream>
#include <string>
using namespace std;

int main()
{
    long N;
    char str[100]={'\n'};
    int number[3]={9,3,7};
    int k=0;
    long sum =0;
    int temp =0;
    int j =0;
    int temp2 =0;
    int number2 =0 ;
    int length = 0;
    cin>>N;
    while (N--)
    {
        sum =0;
        temp  =0;
        number2 = 0;
        j=0;
        k++;
        cin>>str;
        length = strlen(str)-1;
        for (int i=length,j=0;i>=0;i--,j++)
        {
            if (str[i]=='?')
            {
                temp=i;
                number2 = j;
            }
            else
                sum+=(str[i]-48)*number[j%3];
        }
        for (int i=1;i<10;i++)
        {
            temp2 = number[number2%3] * i;
            if (!((temp2+sum)%10))
            {
                str[temp] = i+'0';
            }
        }
        cout<<"Scenario #"<<k<<":\n";
        cout<<str<<endl<<endl;
        memset(str,'\n',100);
    }
    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator