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

为什么这个程序用GCC不过,而C++就过了呢????

Posted by Grope at 2004-05-02 21:32:45 on Problem 1519
#include<iostream>
using namespace std;
char number[1000];
int root,i,temp;
int main()
{
    while(cin>>number&&number[0]!='0'){
        root=0;
        for(i=0;number[i];i++)
             root+=number[i]-'0';
        while(root>9){
            temp=root;
            root=0;
            while(temp)
                root+=temp%10,temp/=10;
        }
        cout<<root<<endl;
    }
    return 1;
}

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