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 |
下面的程序只是获取输入时,用stream就WA,用scanf就AC,是不是编译器有问题?#include <stdio.h> #include <iostream.h> #include <string.h> char* Habb[] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"}; char* Tz[] = {"imix" , "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; int trans(int day, int mon, int year) { int tot; tot = year*365 + mon*20 + day; //cout<<"total:"<<tot<<endl; //printf("year:%d, month:%d, day:%d\n", year, mon, day); return tot; } int transMon(char *str) { int i; for (i=0; i<19; i++) { if (strcmp(str, Habb[i]) == 0) { break; } } return i; } int main() { int N; int day, mon, year, tot; char tStr[20]; freopen("a.txt", "r", stdin); scanf("%d", &N); //此处换成 cin>>N; 输入的话就是WA??? printf("%d\n", N); while (N-- > 0) { scanf("%d. %s %d", &day, tStr, &year); mon = transMon(tStr); tot = trans(day, mon, year); printf("%d %s %d\n", 1+(tot%13), Tz[tot%20], tot/260); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator