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

下面的程序只是获取输入时,用stream就WA,用scanf就AC,是不是编译器有问题?

Posted by zhangds at 2006-01-24 22:44:46 on Problem 1008
#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:
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