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

直接用int會OLE,龍龍int都不行,我去

Posted by KatrineYang at 2016-11-06 12:09:30 on Problem 1519
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int d(int n){
	int r = 0;
	while(n>0){
		r+=n%10;
		n/=10;
	}
	return r;
}

int main() {
	int n;
	while(1){
		n = 0;
		while(1){
			char c = getchar();
			if(c < '0' || c > '9') break;
			n += (c-'0');
		}
		if(!n) break;
		while(n>9){
			n=d(n);
		}
		cout << n << endl;
	}
	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