stonya


私信TA

用户名:stonya

访问量:11754

签 名:

来颗呆桃

等  级
排  名 1077
经  验 3070
参赛次数 1
文章发表 38
年  龄 18
在职情况 学生
学  校
专  业 计算机科学与技术

  自我简介:


解题思路:    在线处理,实部与实部相加,虚部与虚部相加

注意事项:    本地运行时,要结束程序,输入完所有测试数据,按一下回车,再按ctrl + z,再按一下回车,即可看到结果

参考代码:

#include <bits/stdc++.h>
using namespace std;

int main() {
	int a, b;
	int x = 0, y = 0;
	while(cin >> a >> b) {
		x += a, y += b;
	} 
	cout << x << '+' << y << 'i';
	return 0;
}


 

0.0分

3 人评分

  评论区

有数量的时候可以不用回车
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main()
{
    int a, b;

    int x = 0, y = 0;
    for(int i=0;i<10;i++)
    {
        cin >> a >> b;
        x += a, y += b;
    }
    cout << x << '+' << y << 'i';
    return 0;
}
2022-04-30 13:24:18
  • «
  • 1
  • »