TJU1001---天大OJ题

This is the first problem for test.

Since all we know the ASCII code, your job is simple: Input numbers and output corresponding messages.

Input

The input will contain a list of positive integers separated by whitespaces(spaces, newlines, TABs).
Please process to the end of file (EOF).
The integers will be no less than 32.

Output

Output the corresponding message.
Note there is NOT a newline character in the end of output.

Sample Input

72 101 108 108 111 44
32 119 111 114 108 100 33

Sample Output

Hello, world!
//空格是32 数字的ascll码在48到57之间
void TJU1001() {
	char buffer[100];
	int i = 0;             //指针
	int a;
	cin.getline(buffer, 100);   //接收一行数据
	while (buffer[i] != '\0') {
		a = 0;
		while (buffer[i] != 32 && buffer[i] != 0) {
			a *= 10;
			a += (int)buffer[i++] - 48;
		}
		cout << (char)a;
		while (buffer[i] == 32)
			i++;
		if (buffer[i] == 0) {
			//到了末尾就要从零开始
			cin.getline(buffer, 100);
			i = 0;
		}
	}
}

猜你喜欢

转载自blog.csdn.net/haohulala/article/details/83037369
今日推荐