当前位置:网站首页>暑假刷题嗷嗷嗷嗷
暑假刷题嗷嗷嗷嗷
2022-07-06 09:30:00 【牙疼想吃桃】
因为最近的工作内容不涉及编程
我已经很久很久很久没有敲过代码了
现在因为学校课程
要快速回顾一下啦
考试一时爽
上学泪两行
加上十月份还有体测
最近还有各种运动比赛
啊啊啊啊啊啊啊啊啊啊加油吧
第一题
题目:
计算两个32位整数A和B的和!
输入 输入数据有多组,每组为一行,包括两个不超过二进制32位的整数。
输出 对每组输入,在单独的行中输出结果。
示例输入
1 2
-1 1
示例输出
3
0
注意点:极限输入
#include<stdio.h>
int main()
{
long a, b;
while(scanf("%ld %ld", &a, &b)!=EOF)
{
printf("%ld\n", a+b);
}
return 0;
}
第二题
题目:
计算两个32位整数A和B的和!
输入 输入数据的第一行为一个整数TT,表示有TT组数据。随后的TT行中,每行有两个整数A和B。
输出 对每组输入,在单独的行中输出结果。
示例输入
2
1 2
-1 1
示例输出
3
0
注意点:
Scanner是SDK1.5新增的一个类,可使用该类创建一个对象。
Scanner input=new Scanner(System.in);
input可以调用nextInt()、next()、nextLine()等方法
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.(一般用于字符串)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++) {
//每一行只有两个数
a = sc.nextInt();
b = sc.nextInt();
System.out.println(a + b);
}
sc.close();
}
}
第三题
题目:
计算两个32位整数A和B的和!
输入 输入数据有多组,每组为一行,包括两个32位整数。若两个整数均为0,表示输入结束。
输出 对每组输入,在单独的行中输出结果。
示例输入
1 2
-1 1
0 0
示例输出
3
0
注意点:
判断条件
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();
}
}
第四题
题目
若干32位整数求和。
输入
输入数据有多组,每组为一行,包括若干个32位整数。行首数字为该行中后续数字的个数,若行首的数值为0,表示输入结束。输出
对每组输入,在单独的行中输出结果。示例输入
5 1 2 3 4 5
2 -1 1
0
示例输出
15
0
注意点:
每一行不止有两个数据,多行数据
#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;
}
第五题
题目
若干32位整数求和。
输入
输入数据的第一行为一个整数TT,表示有TT组测试数据,每组为一行。随后的TT行中,每行第一个数为一个整数NN,随后有NN个32位整数。
输出
对每组输入,在单独的行中输出结果。
示例输入
3
5 1 2 3 4 5
2 -1 1
1 0
示例输出
15
0
0
边栏推荐
- After the subscript is used to assign a value to the string type, the cout output variable is empty.
- 「博士毕业一年,我拿下 ACL Best Paper」
- Shell_ 06_ Judgment and circulation
- arithmetic operation
- TCP's three handshakes and four waves
- MySQL date function
- 亮相Google I/O,字节跳动是这样应用Flutter的
- Many papers on ByteDance have been selected into CVPR 2021, and the selected dry goods are here
- Eight part essay that everyone likes
- Basic knowledge of assembly language
猜你喜欢
Fdog series (VI): use QT to communicate between the client and the client through the server (less information, recommended Collection)
Shell_ 05_ operator
8086 CPU internal structure
Which is more important for programming, practice or theory [there are some things recently, I don't have time to write an article, so I'll post an article on hydrology, and I'll fill in later]
MySQL optimization notes
字节跳动海外技术团队再夺冠:高清视频编码已获17项第一
Eureka single machine construction
逻辑运算指令
字节跳动2022校招研发提前批宣讲会,同学们最关心的10个问题
Idea resolving jar package conflicts
随机推荐
Interview collection library
Activiti directory (V) reject, restart and cancel process
Which is more important for programming, practice or theory [there are some things recently, I don't have time to write an article, so I'll post an article on hydrology, and I'll fill in later]
MySQL date function
在 vi 编辑器中的命令模式下,删除当前光标处的字符使用 __ 命 令。
8086 CPU 内部结构
Activiti目录(一)重点介绍
字节跳动春招攻略:学长学姐笔经面经,还有出题人「锦囊」
koa中间件
MySQL string function
[graduation project] QT from introduction to practice: realize imitation of QQ communication, which is also the last blog post in school.
Typescript basic operations
À propos de l'utilisation intelligente du flux et de la carte
MySQL字符串函数
Control transfer instruction
汇编语言基础知识
服务器端渲染(SSR)和客户端渲染(CSR)的区别
~81 long table
Mongodb learning notes
TCP's three handshakes and four waves