救命!救命! [英] Help! help!

查看:85
本文介绍了救命!救命!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

告诉我它是什么错?


当我输入12345时,它会给我1 2 3 4 5,但是当我输入整数时>
输入太棒了,它不会给我我想要的东西。例如,如果我是
类型78569,我想得到7 8 5 6 9 ,但结果是

wrong.why ?????

#include< stdio.h>

int main()

{int x,y,z,m,n,w;


printf(给我一个整数\ n);

scanf("%d"& x);


y = x / 10000;

z = x%10000/1000;

m = x%1000/100;

n = x%100/10;

w = x%10;


printf("%d%d%d%d%d",y,z,m,n,w);


返回0;}

Tell me what fault it is ?

when I type 12345,it''ll give me "1 2 3 4 5",but when the integer I
type in is too great ,it''ll not give me what I want.For example,if I
type 78569,I want to get "7 8 5 6 9",but the result is
wrong.why?????
#include<stdio.h>
int main()
{ int x,y,z,m,n,w;

printf("Give me an integer\n");
scanf("%d",&x);

y=x/10000;
z=x%10000/1000;
m=x%1000/100;
n=x%100/10;
w=x%10;

printf("%d %d %d %d %d",y,z,m,n,w);

return 0;}

推荐答案



" questions" < me ********** @ yahoo.cn在留言中写道

新闻:4a ******************** ************** @ z6g2000p re.googlegroups.com ...

"questions" <me**********@yahoo.cnwrote in message
news:4a**********************************@z6g2000p re.googlegroups.com...

告诉我它是什么错?
当我输入12345时,
,它会给我1 2 3 4 5,但是当我输入的整数值为
时太大了,它'我不会给我我想要的东西。例如,如果我

输入78569,我想获得7 8 5 6 9,但结果是

错误。为什么?????


#include< stdio.h>

int main()

{int x ,y,z,m,n,w;


printf(给我一个整数\ n);

scanf("%) d",& x);


y = x / 10000;

z = x%10000/1000;

m = x %1000/100;

n = x%100/10;

w = x%10;


printf("% d%d%d%d%d,y,z,m,n,w);


返回0;}
Tell me what fault it is ?

when I type 12345,it''ll give me "1 2 3 4 5",but when the integer I
type in is too great ,it''ll not give me what I want.For example,if I
type 78569,I want to get "7 8 5 6 9",but the result is
wrong.why?????
#include<stdio.h>
int main()
{ int x,y,z,m,n,w;

printf("Give me an integer\n");
scanf("%d",&x);

y=x/10000;
z=x%10000/1000;
m=x%1000/100;
n=x%100/10;
w=x%10;

printf("%d %d %d %d %d",y,z,m,n,w);

return 0;}



将12345转换为十六进制。

多少字节你需要存储这个号码吗?

将78569转换为十六进制。

你需要多少字节来存储这个号码?


int中有多少字节?

Richard

Convert 12345 to hex.
How many bytes do you need to store that number?
Convert 78569 to hex.
How many bytes do you need to store that number?

How many bytes in an int?

Richard


问题< me ********* *@yahoowwwrites:
questions <me**********@yahoo.cnwrites:

告诉我它是什么错?


当我输入12345时,它会给我1 2 3 4 5,但是当我输入的整数是
太大了,它就不会给我我想要的东西。例如,如果我

类型78569,我想得到7 8 5 6 9,但结果是

wrong.why ?????
Tell me what fault it is ?

when I type 12345,it''ll give me "1 2 3 4 5",but when the integer I
type in is too great ,it''ll not give me what I want.For example,if I
type 78569,I want to get "7 8 5 6 9",but the result is
wrong.why?????



不适合我。我得到7 8 5 6 9.大概你的系统比我的INT_MAX少了


Not for me. I get 7 8 5 6 9. Presumably your system has INT_MAX less
than mine.


#include< stdio.h>

int main()

{int x,y,z,m,n,w;
#include<stdio.h>
int main()
{ int x,y,z,m,n,w;



尝试long int相反。

Try "long int" instead.


printf(给我一个整数\ n);

scanf("%d",& X);
printf("Give me an integer\n");
scanf("%d",&x);



和%ld在这里匹配

and "%ld" to match here


y = x / 10000;

z = x%10000/1000;

m = x% 1000/100;

n = x%100/10;

w = x%10;


printf("%d %d%d%d%d,y,z,m,n,w);
y=x/10000;
z=x%10000/1000;
m=x%1000/100;
n=x%100/10;
w=x%10;

printf("%d %d %d %d %d",y,z,m,n,w);



和此处。

and here.


返回0;}
return 0;}



-

Ben。

--
Ben.


questions写道:
questions wrote:

当我输入12345时,它会给我1 2 3 4 5,但是当我输入的整数值为
时,它太大了,它就不会给我我想要的东西例如,如果我是
类型78569,我想得到7 8 5 6 9,但结果是

错误。为什么?????


#include< stdio.h>

int main()

{int x,y,z,m,n ,w;


printf(给我一个整数\ n);

scanf("%d",& x);
when I type 12345,it''ll give me "1 2 3 4 5",but when the integer I
type in is too great ,it''ll not give me what I want.For example,if I
type 78569,I want to get "7 8 5 6 9",but the result is
wrong.why?????
#include<stdio.h>
int main()
{ int x,y,z,m,n,w;

printf("Give me an integer\n");
scanf("%d",&x);



x太大而不适合int。如果你想在PC上使用大于int的大小的数字,请使用较大的类型,例如long。


另外:不要使用scanf - 对于初学者来说这是一个不安全的功能,因为你可以轻松地创建缓冲区溢出。


-

Mark McIntyre


CLC常见问题< http://c-faq.com/>

CLC自述文件:< http://www.ungerhu .com / jxh / clc.welcome.txt>

x is too large to fit into an int. if you want numbers greater than the
size of an int on your PC, use a larger type such as long.

Also: don''t use scanf - its an unsafe function for beginners due to the
ease with which you can create buffer overruns.

--
Mark McIntyre

CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>


这篇关于救命!救命!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆