| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2161 人关注过本帖
标题:请问各位高手这个程序有什么错误?
取消只看楼主 加入收藏
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:4 
请问各位高手这个程序有什么错误?
#include<stdio.h>
#define Y 5
void copy_arr(double sourse,double target1,int n);
void copy_ptr(double sourse,double target2,int n);
void main()
{
    double arr[5]={1.1,2.2,3.3,4.4,5.5};
    double cop1[5];
    double cop2[5];
    copy_arr(arr,cop1,5);
    copy_ptr(arr,cop2,5);
}
void copy_arr(double sourse,double target1,int n)
{
    int i;
    int m;
    m=0;
    for(i=0;i<5;i++)
        {
            cop1[i]=arr[m];
            m++;
        }
    for(i=0;i<5;i++)
    printf{"the array after copy is %f",cop1[i]};
}
void copy_ptr(double sourse,double target2,int n)
{
    double *pt;
    int i,m;
    pt=arr;
    for(i=0,m=0;i<5;i++)
    {   
        cop2[i]=*(pt+m);
        m++;
    }

    for(i=0;i<5;i++)
    printf{"the array after copy is %f",cop2[i]};
}
搜索更多相关主题的帖子: include double 
2016-02-27 13:04
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
收藏
得分:0 
回复 2楼 蓝色风暴cl
高手 能不能帮忙改一下或者帮忙提一下这里错误地方的知识点,我是新手
2016-02-27 13:17
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
收藏
得分:0 
回复 4楼 qq1023569223
您真的太厉害了,请问我可以加您QQ吗
2016-02-27 23:20
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
收藏
得分:0 
回复 8楼 qq1023569223
为什么这两个函数里边不用声明sourse
void copy_arr(double sourse[],double target1[],int n)
{
    int i;
    for(i=0;i<5;i++)
    {
        target1[i]=sourse[i];
    }
}
void copy_ptr(double sourse[],double target2[],int n)
{
    double *pt;
    int i,m;
    pt=sourse;
    for(i=0,m=0;i<5;i++)
    {
        target2[i]=*(pt+m);
        m++;
    }
}
而8楼的需要,而且输出的内容是错误的?
2016-02-28 16:52
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
收藏
得分:0 
回复 10楼 qq1023569223
谢谢找到原因了
2016-02-28 17:18
快速回复:请问各位高手这个程序有什么错误?
数据加载中...
 
   



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

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