| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 579 人关注过本帖
标题:求各位大侠帮忙啊!!输入一个数,如何得出小的当中最大的,大的当中最小的 ...
只看楼主 加入收藏
chlhch1985
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-5-28
收藏
 问题点数:0 回复次数:3 
求各位大侠帮忙啊!!输入一个数,如何得出小的当中最大的,大的当中最小的??
# define N 36
main()
{struct Kmz
{float v;
  float k;
 }vKmz[36]={{200,0.0095},{260,0.0095},{280,0.0096},{300,0.0098},{320,0.0100},{340,0.0104},{360,0.0105},{380,0.0105},{400,0.0105},{420,0.0104},{440,0.0103},{460,0.0102},{480,0.0101},{500,0.0101},{520,0.0100},{540,0.0099},{560,0.0098},{580,0.0098},{600,0.0097},{620,0.0096},{640,0.0096},{660,0.0095},{680,0.0095},{700,0.0094},{720,0.0094},{740,0.0093},{760,0.0092},{780,0.0091},{800,0.0091},{850,0.0090},{900,0.0089},{950,0.0088},{1000,0.0088},{1050,0.0088},{1100,0.0087},{1150,0.0086}};
输入一个数,得出比它小的当中最大的,比它大的当中最小的!!
例如:输入:270;得出260,0095和280,0096!
应该用什么方法啊??

[[it] 本帖最后由 chlhch1985 于 2008-5-28 03:46 编辑 [/it]]
搜索更多相关主题的帖子: 大侠 输入 
2008-05-28 03:44
storm_2008
该用户已被删除
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽
2008-05-28 17:01
flyue
Rank: 10Rank: 10Rank: 10
来 自:江南西道
等 级:贵宾
威 望:19
帖 子:3465
专家分:1563
注 册:2006-6-20
收藏
得分:0 
循环每项,记录找到的最小的,继续循环,比较当前项是否小于前面找到的最小的,如果是,把此项记录为最小的比较项

天之道,损有余而补不足.人之道则不然,损不足以奉有余.孰能有余以奉天下,唯有道者.
2008-05-28 18:47
chlhch1985
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-5-28
收藏
得分:0 
# define N 36
main()
{struct Kmz
   {float v;
    float k;
    }vKmz[N]={{200,0.0095},{260,0.0095},{280,0.0096},{300,0.0098},{320,0.0100},{340,0.0104},{360,0.0105},{380,0.0105},{400,0.0105},{420,0.0104},{440,0.0103},{460,0.0102},{480,0.0101},{500,0.0101},{520,0.0100},{540,0.0099},{560,0.0098},{580,0.0098},{600,0.0097},{620,0.0096},{640,0.0096},{660,0.0095},{680,0.0095},{700,0.0094},{720,0.0094},{740,0.0093},{760,0.0092},{780,0.0091},{800,0.0091},{850,0.0090},{900,0.0089},{950,0.0088},{1000,0.0088},{1050,0.0088},{1100,0.0087},{1150,0.0086}};
float a,x,y;
int i,j,k;
scanf ("%f",&a);
    for (j=0;vKmz[j].v<a&&j<=35;j++);
    for (i=0;i<j;i++);
{ printf ("%f ,%f \n",vKmz[i].v,vKmz[i-1].v);}
}
今天无意间编成这样,可以得出结果!但是完全不知道什么意思!各位大大能不能帮我解释一下!谢谢了!
2008-05-29 01:07
快速回复:求各位大侠帮忙啊!!输入一个数,如何得出小的当中最大的,大的当中最 ...
数据加载中...
 
   



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

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