当前位置:网站首页>暑假刷题嗷嗷嗷嗷
暑假刷题嗷嗷嗷嗷
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
边栏推荐
- Data transfer instruction
- Basic knowledge of assembly language
- Error occurred during initialization of VM Could not reserve enough space for object heap
- 8086 内存
- Solr word segmentation analysis
- Monomer application concept
- Description of project structure configuration of idea
- Introduction to microservices
- Fdog series (4): use the QT framework to imitate QQ to realize the login interface, interface chapter.
- 吴军三部曲见识(五) 拒绝伪工作者
猜你喜欢
~83 form introduction
How to configure hosts when setting up Eureka
程序员定位解决问题方法论
Error occurred during initialization of VM Could not reserve enough space for object heap
Data config problem: the reference to entity 'useunicode' must end with ';' delimiter.
MySQL optimization notes
Resume of a microservice architecture teacher with 10 years of work experience
Programmer orientation problem solving methodology
原型链继承
Full record of ByteDance technology newcomer training: a guide to the new growth of school recruitment
随机推荐
DOS function call
"One year after graduation, I won ACL best paper"
Activiti目录(四)查询代办/已办、审核
Assembly language addressing mode
Compile homework after class
Error occurred during initialization of VM Could not reserve enough space for object heap
Introduction to microservices
Fdog series (VI): use QT to communicate between the client and the client through the server (less information, recommended Collection)
数据传送指令
[graduation project] QT from introduction to practice: realize imitation of QQ communication, which is also the last blog post in school.
Activiti directory (I) highlights
汇编语言寻址方式
Fdog series (III): use Tencent cloud SMS interface to send SMS, write database, deploy to server, web finale.
koa中间件
在 vi 编辑器中的命令模式下,删除当前光标处的字符使用 __ 命 令。
arithmetic operation
Go language uses the thrift protocol to realize the client and service end reports not enough arguments in call to oprot Writemessagebegin error resolution
Shell_ 04_ Shell script
Activiti directory (III) deployment process and initiation process
Basic knowledge of assembly language