C++编程,有几道题目不会,大家帮帮忙啊

1.Writeaprogramthatrepeatedlyasksyoutoenterpairsofnumbersuntilatleastoneofthepairisze... 1. Write a program that repeatedly asks you to enter pairs of numbers until at least one of the pair is zero. For each pair, the program should use a function to calculate the Harmonic Mean(调和平均数)of the numbers ,and use another function to calculate the Arithmetic Mean(算术平均数)of the numbers. Two functions should return the answer to main(), which reports the result. The harmonic mean of the numbers can be calculated as follows:harmonic mean = 2.0 * x * y / (x + y)
写一个程序,一直让你输入两个数字(一组),直到其中一个数字为0,才不让你继续.对于每组数字,计算它们的调和平均数和算术平均数,然后输出.
调和平均数是这样的: 2.0 * x * y / (x + y)
展开
 我来答
wwchang
2008-03-29 · TA获得超过419个赞
知道小有建树答主
回答量:374
采纳率:0%
帮助的人:237万
展开全部
整个程序最外面的大循环可以用while(1)弄成死循环,里面再if(0==i*j) break;就行了。至于别的,就用scanf和printf或者cin和cou语句管输入输出,计算公式你自己也列出来了,这个代码应该很简单啊,怎么没人回答啊??
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
victortkl
2008-03-31 · TA获得超过676个赞
知道小有建树答主
回答量:314
采纳率:100%
帮助的人:392万
展开全部
那我来吧。。。
#include<iostream>
using namespace std;

int main()
{
int i,j;
while (1)
{
cin>>i>>j;
if (i*j==0)
break;
else
cout<<2.0*i*j/(i+j)<<endl;
}
return 0;
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式