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

Re:帮忙指错的有奖

Posted by 0912070002 at 2010-06-17 13:05:09 on Problem 2498
In Reply To:帮忙指错的有奖 Posted by:wwwwwwking at 2008-04-01 16:41:14
> #include <iostream>
> using namespace std;
> 
> int main ()
> {
>     int t,i,p,len,j,sum;
>     char input[10];
>     cin>>t;
>     for (i=1;i<=t;++i)
>     {
>         sum=0;
>         cin>>input;
>         len=strlen(input)-1;
>         for (j=len;j>=0;--j)
>         {
>             if (input[j]=='?')
>             {
>                   p=j;
>             }
>             else 
>             {
>                  if ((len-j)%3==0)
>                  { sum+=(input[j]-'0')*9; }
>                  if ((len-j)%3==1)
>                  { sum+=(input[j]-'0')*3; }
>                  if ((len-j)%3==2)
>                  { sum+=(input[j]-'0')*7; }
>             }
>         }
>         sum%=10;
>         if ((len-p)%3==0)
>         { 
>              for (j=0;j<10;++j)
>              {
>                  if (j*9%10+sum==10)
>                  {
>                       input[p]=j+'0';
>                  }
>              }
>         }
>         if ((len-p)%3==1)
>         { 
>              for (j=0;j<10;++j)
>              {
>                  if (j*3%10+sum==10)
>                  {
>                       input[p]=j+'0';
>                  }
>              }
>         }
>         if ((len-p)%3==2)
>         { 
>              for (j=0;j<10;++j)
>              {
>                  if (j*7%10+sum==10)
>                  {
>                       input[p]=j+'0';
>                  }
>              }
>         }
>         cout<<"Scenario #"<<i<<":\n"<<input<<"\n"<<endl;
>     }
>     system("pause");
>     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