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

我用c写的,为什么老是runtime error????????!!!高手帮忙看看,谢谢!!!

Posted by nmb at 2005-09-08 12:31:48 on Problem 2498
#include"stdio.h"
#include"string.h"

main()
{
    int i,k,j,h,n,sum=0,add,lose,array[4]={0,9,3,7};
    char a[1000][8];

    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%s",a[i]);
    for(i=1;i<=n;i++)
    {
         for(k=1,j=strlen(a[i])-1;j>=0;k++,j--)
            {
                if(k==4)k=1;
                if(a[i][j]!='?')
                    sum+=(a[i][j]-48)*array[k];
                else
                    {add=k;lose=j;}

            }
         for(h=9;h>=0;h--)
         {
            if((h*array[add]+sum)==((h*array[add]+sum)/10*10))
                break;
         }
         a[i][lose]=h+48;
         sum=0;
    }
    for(i=1;i<=n;i++)
    {
        if(i!=n)
            printf("Scenario #%d:\n%s\n\n",i,a[i]);
        else
            printf("Scenario #%d:\n%s\n",i,a[i]);
    }



}

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