| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 514 人关注过本帖
标题:求助7道 C++难题
只看楼主 加入收藏
dlcoffee
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-1-31
收藏
 问题点数:0 回复次数:1 
求助7道 C++难题

No.1
Design and write a C program in 2 float-values (first and second)and call a function with the two values as parameters. The function should use pointers to make sure that
"first" will hold the biggest value after the function has been called.

No.2
Change the function from NO.1 to read in 3 values("first","second" and "third"),call a function,that uses pointers to make "first"the biggest and "third"the smallest value

No 3
Change the function from No.2 to return the average value of the 3 input parameters.


No4 Read 10 temperaturvalues into an array

No5 Validate temperatature to be with in the ragen of 30...60C

No.6 Create 4 functions to calculate:
3.1 the total sum,
3.2 the average value,
3.3 the minimum value,
3.4 the miximum value,

No.7 Finally display the results from 3.1 to 3.4

搜索更多相关主题的帖子: 难题 
2006-01-31 23:15
DarkHero
Rank: 1
等 级:新手上路
威 望:2
帖 子:191
专家分:0
注 册:2006-1-14
收藏
得分:0 

难吗?是你自己不想做吧,我只做了1-3题

void setMax(float *first,const float *second) { //1
if(*first < *second)
*first = *second;
}

void setMaxMin(float *first,const float *second,float* third) { //2
float middle = *second;
if(middle < *third) {
middle = *third;
*third = *second;
}
if(*first < middle) {
if(*first < *third)
*third = *first;
*first = middle;
}
}

float newSetMaxMin(float *first,const float *second,float* third) { //2
float middle = *second;
if(middle < *third) {
middle = *third;
*third = *second;
}
if(*first < middle) {
if(*first < *third)
*third = *first;
*first = middle;
}

return (*first + *second + *third )/3;
}


/*******************************
* Main Function
*******************************/
int main()
{
float f1=12,f2=25,f3=32;
float *f=&f1,*s=&f2,*t=&f3;
cout<<newSetMaxMin(f,s,t)<<endl;
cout<<*f<<endl;
cout<<*t<<endl;

return 0;
}


for( ; me.alive() ; ) { 淡泊名利,志存高远 } //Forever
2006-02-01 17:13
快速回复:求助7道 C++难题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016361 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved