| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1405 人关注过本帖
标题:刚学C求大哥们帮忙解惑
只看楼主 加入收藏
chen5169
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2018-7-9
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
刚学C求大哥们帮忙解惑
目前在做c primer plus 第6版 第十章,第十二题
用的dev c++5.11 请问下这个代码哪里出问题了?,运行不了。已经看糊涂了

#include<stdio.h>
void one(double a[],int b);
void one2(int b,double a[]);
void two(short a[][30],int b);
void two2(int a,int b,short c[a][b]);
int main()
{
    double trots[20]={1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
    one(trots,20);
    one2(20,trots);
    short clops[10][30]={
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    };
    two(clops,10);
    two2(10,30,clops);
}
void one(double a[],int b)
{
    double z=0;
    int x;
    for(x=0;x<b;x++)
    z+=a[x];
    printf("%f\n",z);
}
void one2(int b,double a[])
{
    double z=0;
    int x;
    for(x=0;x<b;x++)
    z+=a[x];
    printf("%f\n",z);
}
void two(short a[][30],int b)
{
    short z=0;
    int x,y;
    for(x=0;x<b;x++)
       for(y=0;y<30;y++)
          z+=a[x][y];
    printf("%d\n",z);
}
void two2(int a,int b,short c[a][b])
{
    short z=0;
    int x,y;
    for(x=0;x<a;x++)
    for(y=0;y<b;y++)
    z+=a[x][y];
    printf("%d\n",z);
}

[此贴子已经被作者于2018-7-9 21:39编辑过]

搜索更多相关主题的帖子: void double int short for 
2018-07-09 20:57
大大哟nice
Rank: 2
等 级:论坛游民
威 望:3
帖 子:15
专家分:30
注 册:2016-11-26
收藏
得分:20 
void two2(int a,int b,short c[a][b])
{
    short z=0;
    int x,y;
    for(x=0;x<a;x++)
    for(y=0;y<b;y++)
    z+=a[x][y];//a是int类型变量不是数组啊! 个人感觉应该是 z+=c[x][y];
    printf("%d\n",z);
}


[此贴子已经被作者于2018-7-9 22:07编辑过]

2018-07-09 22:04
chen5169
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2018-7-9
收藏
得分:0 
回复 2楼 大大哟nice
谢谢大哥帮助。终于搞定了
2018-07-10 06:54
快速回复:刚学C求大哥们帮忙解惑
数据加载中...
 
   



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

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