| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 620 人关注过本帖
标题:[刚开始学编个程序老运行不出来请高手指导下}
只看楼主 加入收藏
qiuxu777777
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-6-8
收藏
 问题点数:0 回复次数:5 
[刚开始学编个程序老运行不出来请高手指导下}
百钱求百鸡
  void main()                                                                  
│{                                                                             
│int cocks=0,hens,chicks;                                                      
│while(cocks<=19)                                                              
                                                                              
│{                                                                             
│hens=0;                                                                       
│while(hens<=33)                                                               
│{                                                                             
│chicks=100-cocks-hens;                                                        
│if(5.0*cocks+3.0*hens+chicks/3.0==100)                                       
│printf("%d %d %d\n",cocks,hens,chicks);                                       
│}                                                                             
│hens++;                                                                       
│}                                                                             
│cocks++;                                                                     
│}
搜索更多相关主题的帖子: cocks 指导 运行 
2008-06-08 10:45
qiuxu777777
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-6-8
收藏
得分:0 
哪里出了问题
2008-06-08 10:45
yjcf
Rank: 1
来 自:西安工业大学
等 级:新手上路
帖 子:145
专家分:0
注 册:2008-3-29
收藏
得分:0 
晕~你这连套了两个死循环唉~~~
这样改:
void main()                                                                  
{                                                                             
int cocks=0,hens,chicks;                                                      
while(cocks<=19)                                                              
                                                                              
{                                                                             
hens=0;                                                                       
while(hens<=33)                                                               
{                                                                             
chicks=100-cocks-hens;                                                        
if(5.0*cocks+3.0*hens+chicks/3.0==100)                                       
printf("%d %d %d\n",cocks,hens,chicks);                                       
hens++;
}                                                                             
 cocks++;                                                                     
}                                                                             
                                                                  
}

泾溪石险人竞慎,终岁不闻倾覆人。却是平流无石处,时时闻说有沉论。
2008-06-08 10:52
qiuxu777777
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-6-8
收藏
得分:0 
谢谢你老大
2008-06-08 10:55
beyond0702
Rank: 1
来 自: 桂 林
等 级:新手上路
帖 子:219
专家分:0
注 册:2007-11-17
收藏
得分:0 
#include<stdio.h>
void main()
{
  int cocks,hens,chicks,i,j,k;
  for(cocks=1;cocks<=100;cocks++)
    for(hens=1;hens<=100;hens++)
       for(chicks=1;chicks<=100;chicks++)
          if(5*cocks+3*hens+chicks/3==100)
             { britf("%d %d %d",cocks,hens,chicks);break;}



}

蝴 蝶 颤 动 了 翅 膀 !!!
2008-06-09 01:15
广陵绝唱
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:29
帖 子:3607
专家分:1709
注 册:2008-2-15
收藏
得分:0 
回复 5# beyond0702 的帖子
楼上的在浪费资源。
2008-06-09 02:24
快速回复:[刚开始学编个程序老运行不出来请高手指导下}
数据加载中...
 
   



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

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