正文

ACM II2008-04-06 00:28:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/ieee/33941.html

分享到:

输入_第三类: l       输入不说明有多少个Input Block,但以某个特殊输入为结束标志。        参见:HDOJ_1091 Problem Description Your task is to Calculate a + b.     Input Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed.     Output For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.     Sample Input 1 5 10 20 0 0     Sample Output 6 30     Author lcy     Recommend JGShining   Hdoj_1091源代码: #include <stdio.h> int main() {        int a, b;        while(scanf("%d %d", &a, &b) && (a != 0 && b != 0))               printf("\n%d\n", a + b); }   上面的程序有什么问题?   本类输入解决方案: l       C语法:        while(scanf("%d",&n)  && n!=0 )        {     .... }   l       C++语法:        while( cin >> n && n != 0 ) {     .... }   输入_第四类: l       以上几种情况的组合 Oj1092 Problem Description Your task is to Calculate the sum of some integers.     Input Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.     Output For each group of input integers you should output their sum in one line, and with one line of output for each line in input.     Sample Input 4 1 2 3 4 5 1 2 3 4 5 0     Sample Output 10 15     Author lcy     Recommend JGShining   代码清单à #include <stdio.h> int main() {        int a = 1, b = 0;        while(a != 0)        {               b = 0;               while(getchar() != '\n')               {                      scanf("%d", &a);                      b = b + a;               }               printf("%d\n", b);               scanf("%d", &a);        } }   Resultà 4 1 2 3 4 10 5 1 2 3 4 5 15 0   另附: Problem Description Calculate A + B.     Input Each line will contain two integers A and B. Process to end of file.     Output For each case, output A + B in one line.     Sample Input 1 1     Sample Output 2     Author HDOJ   代码清单: #include <stdio.h> int main() {        int a, b;        while(scanf("%d %d", &a, &b) == 2)               printf("%d\n", a + b);        return 0;/*返回值*/ } /*留个空行*/   /*#include <iostream>*/ /*using namespace std;*/ /*int main()*/ /*{*/ /*   int i, j;*/ /*   while(cin >> i >> j)*/ /*      cout << i + j << endl;*/ /*  return 0;*/ /*}*/   Hdoj1093à Problem Description Your task is to calculate the sum of some integers.     Input Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.     Output For each group of input integers you should output their sum in one line, and with one line of output for each line in input.     Sample Input 2 4 1 2 3 4 5 1 2 3 4 5     Sample Output 10 15     Author lcy   代码清单: #include <stdio.h> int main() {        int a, b, c, d, i, j;        scanf("%d", &a);        getchar();        for(i=0; i<a; i++)        {                   scanf("%d", &b);               d = 0;               for(j=0; j<b; j++)               {                      scanf("%d", &c);                      d = c + d;               }               printf("%d\n", d);        } }   Hdoj1094à Problem Description Your task is to calculate the sum of some integers.     Input Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.     Output For each test case you should output the sum of N integers in one line, and with one line of output for each line in input.     Sample Input 4 1 2 3 4 5 1 2 3 4 5     Sample Output 10 15     Author lcy     Recommend JGShining   第五类 Problem Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that no one could figure it out without knowing how it worked. You are a sub captain of Caesar's army. It is your job to decipher the messages sent by Caesar and provide to your general. The code is simple. For each letter in a plaintext message, you shift it five places to the right to create the secure message (i.e., if the letter is 'A', the cipher text would be 'F'). Since you are creating plain text out of Caesar's messages, you will do the opposite: Cipher textA B C D E F G H I J K L M N O P Q R S T U V W X Y ZPlain textV W X Y Z A B C D E F G H I J K L M N O P Q R S T U Only letters are shifted in this cipher. Any non-alphabetical character should remain the same, and all alphabetical characters will be upper case.     Input Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. All characters will be uppercase. A single data set has 3 components: Start line - A single line, "START" Cipher message - A single line containing from one to two hundred characters, inclusive, comprising a single message from Caesar End line - A single line, "END" Following the final data set will be a single line, "ENDOFINPUT".     Output For each data set, there will be exactly one line of output. This is the original message by Caesar.     Sample Input START NS BFW, JAJSYX TK NRUTWYFSHJ FWJ YMJ WJXZQY TK YWNANFQ HFZXJX END START N BTZQI WFYMJW GJ KNWXY NS F QNYYQJ NGJWNFS ANQQFLJ YMFS XJHTSI NS WTRJ END START IFSLJW PSTBX KZQQ BJQQ YMFY HFJXFW NX RTWJ IFSLJWTZX YMFS MJ END ENDOFINPUT     Sample Output IN WAR, EVENTS OF IMPORTANCE ARE THE RESULT OF TRIVIAL CAUSES I WOULD RATHER BE FIRST IN A LITTLE IBERIAN VILLAGE THAN SECOND IN ROME DANGER KNOWS FULL WELL THAT CAESAR IS MORE DANGEROUS THAN HE     Source South Central USA 2002  

阅读(5029) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册