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 |
怎么会错?请高手帮忙#include <iostream> #include <queue> using namespace std; queue <int> q; int decimal(int x) { int residue=2147483647;//余数 while(residue!=0) { residue=x%10; q.push(residue); x=x/10; } int sum=0; int i; while(!q.empty()) { i=q.front(); q.pop(); sum+=i; } return sum; } int duodecimal(int x) { int residue=2147483647;//余数 while(residue!=0) { residue=x%12; q.push(residue); x=x/12; } int sum=0; int i; while(!q.empty()) { i=q.front(); q.pop(); sum+=i; } return sum; } int hexadecimal(int x) { int residue=2147483647;//余数 while(residue!=0) { residue=x%16; q.push(residue); x=x/16; } int sum=0; int i; while(!q.empty()) { i=q.front(); q.pop(); sum+=i; } return sum; } void main() { int x=2991; int a,b,c; a=b=c=0; cout<<2992<<endl; while(x<=10000) { int a=decimal(x); int b=duodecimal(x); int c=hexadecimal(x); if(a==b&&b==c) cout<<x<<endl; x++; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator