Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
直接用int會OLE,龍龍int都不行,我去#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator