赞
踩
This is the first problem for test.
Since all we know the ASCII code, your job is simple: Input numbers and output corresponding messages.
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 the corresponding message.
Note there is NOT a newline character in the end of output.
72 101 108 108 111 44 32 119 111 114 108 100 33
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;
- }
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。