题解 | #多组_A+B_EOF形式#

多组_A+B_EOF形式

https://www.nowcoder.com/practice/295063bf1bce4c2e819a8f18a5efcd20

解题思路

用 while 循环重复输入

代码

#include <iostream>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	while(cin>>a>>b)
		cout<<a+b<<'\n';
	return 0;
}
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a,b;
        while(sc.hasNext()){
            a=sc.nextInt();
            b=sc.nextInt();
            System.out.println(a+b);
        }
    }
}
while True:
    try:
        a,b=map(int,input().split())
        print(a+b)
    except:
        break

算法及复杂度

  • 算法:无。
  • 时间复杂度:
  • 空间复杂度:
全部评论

相关推荐

05-12 17:28
已编辑
门头沟学院 硬件开发
ldf李鑫:不说公司名祝你以后天天遇到这样的公司
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务