第8届浙江省程序设计竞赛点评beta » ZOJ3487

ZOJ3487
ZOJ3487.cpp


#include <cstdio>
#include <cassert>

const char* s[] = {"th", "st", "nd", "rd"};

int main() {
	int re, n;

	scanf("%d", &re);
	for (int ri = 1; ri <= re; ++ri) {
		assert(scanf("%d", &n) == 1);
		assert(0 <= n && n < 1000000000);
		printf("%d%s\n", n, s[n / 10 % 10 != 1 && n % 10 < 4 ? n % 10 : 0]);
	}
	assert(scanf("%d", &n) == EOF);

	return 0;
}

//Run ID 	Submit Time 	Judge Status 	Problem ID 	Language 	Run Time(ms) 	Run Memory(KB) 	User Name 	Admin
//466 	2011-04-15 01:16:10 	Accepted 	A 	C++ 	10 	180 	watashi 	Source
Leave a Reply