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 |
c++能过,g++不行;应该还是程序有点问题In Reply To:Re:同样的程序在浙大那边ac了,这里却wa Posted by:jasonchen at 2005-02-26 18:13:44 或者是这里的win版的g++编译器和zoj的linux版的在某些时候有差别 > #include <iostream> > #include <cmath> > #include <algorithm> > #define MAX 10000 > > using namespace std; > > void swap(int *x, int *y); > > int > main(void) > { > int table[MAX]; > double tmp; > int i, j, k, l; > int s; > int n; > int fir, sec; > char suf[3]; > > s = 0; > for (i = 0; i <= 30; ++i) > for (j = 0; j <= 19; ++j) > for (k = 0; k <= 13; ++k) > for (l = 0; l <= 11; ++l) > { > tmp = pow((double)2, (double)i) * pow((double)3, (double)j) * pow((double)5, (double)k) * pow((double)7, (double)l); > if (tmp <= 2000000000) > table[s++] = tmp; > } > > > > sort(table, table + s); > > cin >> n; > while (n != 0) > { > fir = n % 10; > sec = (n / 10) % 10; > > strcpy(suf, "th"); > if (sec != 1) > { > if (fir == 1 ) > strcpy(suf, "st"); > else if (fir == 2) > strcpy(suf, "nd"); > else if (fir == 3) > strcpy(suf, "rd"); > } > cout << "The " << n << suf << " humble number is " << table[n - 1] << "." << endl; > cin >> n; > } > > return 0; > } > > void > swap(int *x, int *y) > { > int tmp; > > tmp = *x; > *x = *y; > *y = tmp; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator