| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1025 人关注过本帖
标题:求问各位高手这个程序的错误,一直找不出来。谢谢。
只看楼主 加入收藏
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
结帖率:75%
收藏
已结贴  问题点数:10 回复次数:3 
求问各位高手这个程序的错误,一直找不出来。谢谢。
#include<stdio.h>
#define R 5
#define Y 2
void copy_arr(double sourse[][Y],double target1[][Y]);
void main()
{
    double arr[R][Y];
    double arr1[R][Y];
    int x,y;
    arr[R][Y]={1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9,10.6};
    arr1[R][Y]={0};
    copy_arr(arr,arr1);
    printf("the array arr1 is ");
    for(x=0;x<5;x++)
        for(y=0;y<2;y++)
            {printf("%f ",arr1[x][y]);
                if(y=2)
                    printf("\n                 ");
            }

}
void copy_arr(double sourse[][Y],double target1[][Y])
{
    double *pt;
    double *pt1;
    pt=sourse;
    pt1=target1;
    int m;
    int n;
    for(m=0;m<5;m++)
        for(n=0;n<2;n++)
        *(*(pt1+m)+n)=*(*(pt+m)+n);
            
}
搜索更多相关主题的帖子: include double 
2016-02-28 19:45
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
收藏
得分:0 
Compiling...
c primer plus 10.6.c
D:\C语言\c primer plus 10.6.c(10) : error C2059: syntax error : '{'
D:\C语言\c primer plus 10.6.c(11) : error C2059: syntax error : '{'
D:\C语言\c primer plus 10.6.c(26) : warning C4047: '=' : 'double *' differs in levels of indirection from 'double (*)[2]'
D:\C语言\c primer plus 10.6.c(27) : warning C4047: '=' : 'double *' differs in levels of indirection from 'double (*)[2]'
D:\C语言\c primer plus 10.6.c(28) : error C2143: syntax error : missing ';' before 'type'
D:\C语言\c primer plus 10.6.c(29) : error C2143: syntax error : missing ';' before 'type'
D:\C语言\c primer plus 10.6.c(30) : error C2065: 'm' : undeclared identifier
D:\C语言\c primer plus 10.6.c(31) : error C2065: 'n' : undeclared identifier
D:\C语言\c primer plus 10.6.c(32) : error C2100: illegal indirection
D:\C语言\c primer plus 10.6.c(32) : error C2100: illegal indirection
D:\C语言\c primer plus 10.6.c(32) : error C2106: '=' : left operand must be l-value
执行 cl.exe 时出错.
2016-02-28 20:01
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:10 
最严重的是二维数组指针用错了。下面我改正后的,自己要多思考。
程序代码:
#include<stdio.h>
#define R 5
#define Y 2

void copy_arr(double sourse[][Y],double target1[][Y]);

int main()
{
    double arr[R][Y]={{1.1,2.2},{3.3,4.4},{5.5,6.6},{7.7,8.8},{9.9,10.6}};
    double arr1[R][Y];
    int x,y;

    copy_arr(arr,arr1);

    printf("the array arr1 is:\n");
    for(x=0;x<5;x++)
    {
        for(y=0;y<2;y++)  printf("%.1f ",arr1[x][y]);
        printf("\n");
    }

    return 0;
}

void copy_arr(double sourse[][Y],double target1[][Y])
{
    double *pt;
    double *pt1;

    int m;
    int n;
    for(m=0;m<5;m++)
    {
        pt1=target1[m];
        pt=sourse[m];
        for(n=0;n<2;n++)  *(pt1+n)=*(pt+n);
    }
}

   唯实惟新 至诚致志
2016-02-28 21:40
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
收藏
得分:0 
回复 3楼 qq1023569223
好的,谢谢您。
2016-02-29 11:53
快速回复:求问各位高手这个程序的错误,一直找不出来。谢谢。
数据加载中...
 
   



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

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