Based on C # To solve the problem of OJ brush input and output summary (AKOJ1064-1071A + B problem summary ),
Declaration: The question part is the akoj question, and the code is the AC code.
Because my school's oj supports various environments, it is normal to include C #. However, it is relatively idle at home during the summer vacation. In the light of the attitude and purpose of studying C # and reviewing algorithms, then I started to toss up oj again.
The question part is the most basic A + B series. Let's take A look at the input and output of C #.
Question address: http: // 183.167.205.82: 8081/JudgeOnline/problemlist? Volume = 1
This article was originally written by csdn-jtahstu. For more information, see the source. QQ: 1373758426 and blog link: blog.csdn.net/jtahstu
OK
A + B (1)
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 629 Accepted: 352
Description
Your task is to Calculate a + B.
Too easy ?! Of course! I specially designed the problem for acm beginners.
You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.
Input
The input will consist of a series of pairs of integers a and B, separated by a space, one pair of integers per line.
Output
For each pair of input integers a and B you shoshould output the sum of a and B in one line, and with one line of output for each line in input.
Sample Input
1 510 20
Sample Output
630
Source
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AK1064{ class Program { static void Main(string[] args) { string sb; while ((sb = Console.ReadLine()) != null) { string[] s = sb.Split(); int x = int.Parse(s[0]), y = int.Parse(s[1]); Console.WriteLine(x + y); } } }}
The C # Input System is disgusting. It can only read one row at a time, then extract the data in it, convert it to the type you want, and then process it.
A + B (2)
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 459 Accepted: 313
Description
Your task is to Calculate a + B.
Input
Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and B, separated by a space, one pair of integers per line.
Output
For each pair of input integers a and B you shoshould output the sum of a and B in one line, and with one line of output for each line in input.
Sample Input
21 510 20
Sample Output
630
Source
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AK1065{ class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); while (n-- > 0) { string[] sb = Console.ReadLine().Split(); int x = int.Parse(sb[0]), y = int.Parse(sb[1]); Console.WriteLine(x + y); } } }}
It's similar to the previous one. Haha, these questions are similar.
A + B (3)
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 527 Accepted: 283
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 shoshould output their sum in one line, and with one line of output for each line in input.
Sample Input
4 1 2 3 45 1 2 3 4 50
Sample Output
1015
Source
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AK1066{ class Program { static void Main(string[] args) { string sb; while ((sb = Console.ReadLine()) != null) { string[] s = sb.Split(); int n = int.Parse(s[0]); if (n == 0) break; int sum = 0; for (int i = 1; i <= n; i++) sum += int.Parse(s[i]); Console.WriteLine(sum); } } }}
Note that the code for this question has been RE, indicating that there is a difference between the end of the input 0, but that question is AC, I guess the input data is not strictly input in one row, so C # won't be able to read it at all. I will try again. If it is AC later, I will delete this sentence.
A + B (4)
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 380 Accepted: 292
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 shoshould output the sum of a and B in one line, and with one line of output for each line in input.
Sample Input
1 510 200 0
Sample Output
630
Source
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AK1067{ class Program { static void Main(string[] args) { string sb; while ((sb = Console.ReadLine()) != null) { string[] s = sb.Split(); int x = int.Parse(s[0]), y = int.Parse(s[1]); if (x == 0 && y == 0) break; Console.WriteLine(x + y); } } }}
A + B (5)
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 393 Accepted: 256
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 shoshould output their sum in one line, and with one line of output for each line in input.
Sample Input
24 1 2 3 45 1 2 3 4 5
Sample Output
1015
Source
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AK1068{ class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); while (n-- > 0) { string[] s = Console.ReadLine().Split(); int t = int.Parse(s[0]); int sum = 0, i = 1; while (t-- > 0) { sum += int.Parse(s[i]); i++; } Console.WriteLine(sum); } } }}
A + B (6)
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 346 Accepted: 252
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 shoshould 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 45 1 2 3 4 5
Sample Output
1015
Source
The answer to this question is AC, but the three questions are actually RE. Isn't there a few zeros to end? No difference, depressed
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AK1069{ class Program { static void Main(string[] args) { string sb; while ((sb = Console.ReadLine()) != null) { string[] s = sb.Split(); int n = int.Parse(s[0]); //if (n == 0) break; int sum = 0, i = 1; while (n-- > 0) { sum += int.Parse(s[i]); i++; } Console.WriteLine(sum); } } }}
A + B (7)
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 439 Accepted: 258
Description
Your task is to Calculate a + B.
Input
The input will consist of a series of pairs of integers a and B, separated by a space, one pair of integers per line.
Output
For each pair of input integers a and B you shoshould output the sum of a and B, and followed by a blank line.
Sample Input
1 510 20
Sample Output
630
Source
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AK1071{ class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); while (n-- > 0) { string[] s = Console.ReadLine().Split(); int t = int.Parse(s[0]); int sum = 0, i = 1; while (t-- > 0) { sum += int.Parse(s[i]); i++; } Console.WriteLine(sum); Console.WriteLine(); } } }}
OK, how is C # written? It's almost the same. I feel like this. It's the same as C ++ and Java. The difference is that some small details can be used on questions. There is no book at home, C # The things behind me cannot be viewed. I am still learning. Come on!
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.