当前位置:网站首页>Brush questions during summer vacation, ouch ouch
Brush questions during summer vacation, ouch ouch
2022-07-06 17:13:00 【Toothache, want to eat peach】
Because the recent work content does not involve programming
I haven't typed the code for a long time
Now because of the school curriculum
Let's review it quickly
The exam was a blast
School tears two lines
Plus, there are physical tests in October
Recently, there are various sports competitions
Ah, ah, ah, ah, ah, ah, ah, come on
The first question is
subject :
Calculate two 32 An integer A and B And !
Input Multiple groups of input data , Each group is in a row , Including two no more than binary 32 An integer .
Output Enter... For each group , Output the result in a separate line .
Sample input
1 2
-1 1
Sample output
3
0
Be careful : Limit input
#include<stdio.h>
int main()
{
long a, b;
while(scanf("%ld %ld", &a, &b)!=EOF)
{
printf("%ld\n", a+b);
}
return 0;
}
The second question is
subject :
Calculate two 32 An integer A and B And !
Input The first line of input data is an integer TT, Express TT Group data . And then TT In line , Each line has two integers A and B.
Output Enter... For each group , Output the result in a separate line .
Sample input
2
1 2
-1 1
Sample output
3
0
Be careful :
Scanner yes SDK1.5 A new class , You can use this class to create an object .
Scanner input=new Scanner(System.in);
input You can call nextInt()、next()、nextLine() Other methods
nextInt(): it only reads the int value, nextInt() places the cursor in
the same line after reading the input.next(): read the input only till the space. It can’t read two words
separated by space. Also, next() places the cursor in the same line
after reading the input.( Generally used for Strings )nextLine(): reads input including space between the words (that is,
it reads till the end of line \n). Once the input is read, nextLine()
positions the cursor in the next line.
import java.util.Scanner;
public class Main {
public static void main(final String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
long a, b;
for (int i = 0; i < T; i++) {
// There are only two numbers in each line
a = sc.nextInt();
b = sc.nextInt();
System.out.println(a + b);
}
sc.close();
}
}
Third question
subject :
Calculate two 32 An integer A and B And !
Input Multiple groups of input data , Each group is in a row , It includes two 32 An integer . If both integers are 0, End of input .
Output Enter... For each group , Output the result in a separate line .
Sample input
1 2
-1 1
0 0
Sample output
3
0
Be careful :
Judge the condition
import java.util.Scanner;
public class input3 {
public static void main(final String[] args) {
final Scanner sc = new Scanner(System.in);
long a, b;
a = sc.nextInt();
b = sc.nextInt();
while (a != 0 || b != 0){
System.out.println(a + b);
a = sc.nextInt();
b = sc.nextInt();
}
sc.close();
}
}
Fourth question
subject
A number of 32 Bit integer summation .
Input
Multiple groups of input data , Each group is in a row , It includes a number of 32 An integer . The number at the beginning of the line is the number of subsequent numbers in the line , If the value at the beginning of the line is 0, End of input .Output
Enter... For each group , Output the result in a separate line .Sample input
5 1 2 3 4 5
2 -1 1
0
Sample output
15
0
Be careful :
There are more than two data in each row , Multi row data
#include <stdio.h>
int main()
{
long long int a, b, c = 0;
char d;
while (scanf("%lld", &a), a != 0)
{
while (d = getchar(), d != '\n')
{
scanf("%lld", &b);
c += b;
}
printf("%lld\n", c);
c = 0;
}
return 0;
}
Fifth question
subject
A number of 32 Bit integer summation .
Input
The first line of input data is an integer TT, Express TT Group test data , Each group is in a row . And then TT In line , The first number in each line is an integer NN, Then there are NN individual 32 An integer .
Output
Enter... For each group , Output the result in a separate line .
Sample input
3
5 1 2 3 4 5
2 -1 1
1 0
Sample output
15
0
0
边栏推荐
- Full record of ByteDance technology newcomer training: a guide to the new growth of school recruitment
- Flink 解析(五):State与State Backend
- GCC error: terminate called after throwing an instance of 'std:: regex_ error‘ what(): regex
- 亮相Google I/O,字节跳动是这样应用Flutter的
- 汇编语言寻址方式
- 控制转移指令
- DOS function call
- ByteDance 2022 school recruitment R & D advance approval publicity meeting, students' top 10 issues
- The QT program compiled on CentOS lacks a MySQL driven solution
- 吴军三部曲见识(七) 商业的本质
猜你喜欢
Fdog series (VI): use QT to communicate between the client and the client through the server (less information, recommended Collection)
Prototype chain inheritance
Flink 解析(四):恢复机制
Shell_ 03_ environment variable
JVM之垃圾回收器上篇
redux使用说明
Idea resolving jar package conflicts
一个数10年工作经验的微服务架构老师的简历
Assembly language addressing mode
The QT program compiled on CentOS lacks a MySQL driven solution
随机推荐
唯有学C不负众望 TOP5 S1E8|S1E9:字符和字符串&&算术运算符
yum install xxx报错
When it comes to Google i/o, this is how ByteDance is applied to flutter
Only learning C can live up to expectations Top1 environment configuration
Shell_ 05_ operator
Monomer application concept
Some feelings of brushing leetcode 300+ questions
Ce n'est qu'en apprenant que c est à la hauteur des attentes Top5 s1e8 | s1e9: caractères et chaînes & opérateurs arithmétiques
Install docker under windows10 (through Oracle VM VirtualBox)
学习投资大师的智慧
在 vi 编辑器中的命令模式下,删除当前光标处的字符使用 __ 命 令。
vscode
@RestController、@Controller
GCC error: terminate called after throwing an instance of 'std:: regex_ error‘ what(): regex
字节跳动技术面试官现身说法:我最想pick什么样的候选人
服务器端渲染(SSR)和客户端渲染(CSR)的区别
TCP's three handshakes and four waves
Activiti directory (I) highlights
À propos de l'utilisation intelligente du flux et de la carte
Fdog series (V): use QT to imitate QQ to realize login interface to main interface, function chapter.