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

自己想了个办法处理关于9的问题

Posted by yc5_yc at 2012-08-01 14:33:23 on Problem 2196
#include <cstdio>
#include <string.h>
using namespace std;

int main()
{
    char buf[2000];
    while(scanf("%s",buf),(buf[0]!='0')) {
        int len=strlen(buf);
        int tot=0;
        for(int i=0;i<len;i++)
            tot+=buf[i]-'0';
        printf("%d\n",(tot-1)%9+1);
    }
    getchar();getchar();
    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