编程题A-实部与虚部的和
Description
注:本题只需要提交编写的函数部分的代码即可。
求复数a+bi的实部a和虚部b的和,其中a和b都是整数。请编写缺少的函数output。
#include<stdio.h>
#include <iostream>
using namespace std;
struct comp{
int a;
int b;
};
int main()
{
struct comp va;
void output(struct comp cp);
scanf(“%d%d”,&va.a,&va.b);
output(va);
return 0;
}
Input
复数a+bi的实部a和虚部b
Output
实部和虚部的和
Sample Input
1 2
Sample Output
3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#include<stdio.h> #include <iostream> using namespace std; struct comp{ int a; int b; }; int main() { struct comp va; void output(struct comp cp); scanf("%d%d",&va.a,&va.b); output(va); return 0; } void output(comp cp) { cout<<cp.a+cp.b<<endl; } |