| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 683 人关注过本帖
标题:实在是想不出来为什么了,求解!!!!
取消只看楼主 加入收藏
hutianlun
Rank: 2
等 级:论坛游民
帖 子:21
专家分:13
注 册:2013-3-28
结帖率:100%
收藏
已结贴  问题点数:30 回复次数:0 
实在是想不出来为什么了,求解!!!!
程序代码:
#include <stdio.h>
#include <stdlib.h>
void printf_lxheshu(char lx,char shu);
void zhuanhuanhanshu_i(int lxz,long zhuanhuan,long zhuanhuanhou);
void zhuanhuanhanshu_f(int lxz,long zhuanhuan,long zhuanhuanhou);
void yichu_i(long zhuanhuan,long zhuanhuanhou);
void yichu_f(long double zhuanhuan,long double zhuanhuanhou);
int main (void)
{
unsigned char lx[40],shu[40];
    int lxz;
    printf("请输入你要求的类型(有short,int,long,float,double,longdouble):\n");
    scanf("%s",lx);
   printf("请输入你要求的数\n");
        scanf("%s",shu);
    printf("您输入的数的类型是%s,",lx);
    printf("您输入的数是%s,",shu);
lxz =(int)lx[0]+(int)lx[1]+(int)lx[2]+(int)lx[3]+(int)lx[4]+(int)lx[5];
if(atof(shu)!=atol(shu))
{  
    long double zhuanhuan,zhuanhuanhou;
    zhuanhuan = atof(shu);
  zhuanhuanhanshu_f(lxz,zhuanhuan,zhuanhuanhou);

 
   yichu_f(zhuanhuan,zhuanhuanhou);
    
}


if(atof(shu)==atol(shu))
{    
    long zhuanhuan,zhuanhuanhou;
    zhuanhuan = atol(shu); 
zhuanhuanhanshu_i(lxz,zhuanhuan,zhuanhuanhou);

     yichu_i(zhuanhuan,zhuanhuanhou);
      
}

}




void zhuanhuanhanshu_i(int lxz,long zhuanhuan ,long zhuanhuanhou)
{
    if (lxz==560)
   zhuanhuanhou=(short)zhuanhuan;
     if (lxz==739)
   zhuanhuanhou=(int)zhuanhuan;
        if (lxz==651)
    zhuanhuanhou=(long)zhuanhuan;
}


void zhuanhuanhanshu_f(int lxz,long zhuanhuan, long zhuanhuanhou)
{    if (lxz==643)

 zhuanhuanhou=(long double)zhuanhuan;
    if (lxz==635)
zhuanhuanhou=(double)zhuanhuan;
if (lxz==534)
zhuanhuanhou=(float)zhuanhuan;

}

void yichu_i(long zhuanhuan,long zhuanhuanhou)
{   
  if(zhuanhuan==zhuanhuanhou)
      printf("未溢出");
  if(zhuanhuan!=zhuanhuanhou)
     printf("溢出,转换后的数为%d",zhuanhuanhou);
}


 void yichu_f(long double zhuanhuan,long double zhuanhuanhou)
{   
  if( zhuanhuan==zhuanhuanhou)
      printf("未溢出");
  if (zhuanhuan!=zhuanhuanhou)
      printf("溢出,得到数为%f",zhuanhuanhou);

 }


 zhuanhuanhou=(short)zhuanhuan;
     if (lxz==739)
printf("%d",zhuanhuanhou);
   zhuanhuanhou=(int)zhuanhuan;
        if (lxz==651)
    zhuanhuanhou=(long)zhuanhuan;  在这里加printf函数,显示 zhuanhuanhou 的值为3,是正常的

    long zhuanhuan,zhuanhuanhou;
    zhuanhuan = atol(shu);
zhuanhuanhanshu_i(lxz,zhuanhuan,zhuanhuanhou);
 printf("%d",zhuanhuanhou);
     yichu_i(zhuanhuan,zhuanhuanhou);      在这里加printf函数就变成-858993460

我实在是想不通为什么在自定义的函数里 是对的,一出来就错了呢,郁闷死了,求大神教我啊~~~~~~~~~~~~~~~
30分啊~~~我的全部积蓄了,来人拿啊

[ 本帖最后由 hutianlun 于 2013-7-13 03:49 编辑 ]
搜索更多相关主题的帖子: color 
2013-07-13 03:48
快速回复:实在是想不出来为什么了,求解!!!!
数据加载中...
 
   



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

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