| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2162 人关注过本帖
标题:请问各位高手这个程序有什么错误?
只看楼主 加入收藏
荀减一
Rank: 1
等 级:新手上路
帖 子:19
专家分:2
注 册:2016-2-27
收藏
得分:0 
回复 10楼 qq1023569223
谢谢找到原因了
2016-02-28 17:18
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
收藏
得分:0 
回复 11楼 荀减一
这个代码编译没错误,但是结果好奇怪。。。

#include<stdio.h>
void copy_arr(double sourse[],double target1[],int n);
void copy_ptr(double sourse[],double target2[],int n);

int main()
{
    int i;
    double arr[5]={1.1,2.2,3.3,4.4,5.5};
    double cop1[5]={0};
    double cop2[5]={0};
   
    copy_arr(arr,cop1,5);
    copy_ptr(arr,cop2,5);
    printf("the array after copy is:\n");
    for(i=0;i<5;i++)
    {
    printf("%.1f",cop1[i]);
    }
    for(i=0;i<5;i++)
    printf("the array after copy is %.1f\n",cop2[i]);
return 0;
}

void copy_arr(double sourse[],double target1[],int n)
{

    double source[5];
    int i;
    for(i=0;i<5;i++)
    {
        target1[i]=source[i];
    }
}

void copy_ptr(double sourse[],double target2[],int n)
{
    double source[5];
    double *pt;
    int i,m;
    pt=source;
    for(i=0,m=0;i<5;i++)
    {
        target2[i]=*(pt+m);
        m++;
    }  
}


2016-02-28 21:41
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
收藏
得分:0 
回复 8楼 qq1023569223
谢谢!太马虎了。。
2016-02-28 22:02
快速回复:请问各位高手这个程序有什么错误?
数据加载中...
 
   



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

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