哪里出错了? [英] Where is the mistake?

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

问题描述

希望有人可以帮我解决这个问题。

案例1正在使用一个数字条目完美地工作。

案例2是我尝试2时的问题数字输入。

案例1.

#include< stdio.h>

int main()

{

int a,i;


for(i = 1; i< = 3; i ++)

{

scanf("%d",& a);

printf("%d \ n",a);

}

返回0;

}

/ *结果

5

5

15

15

234

234

按任意键继续

* /

结果显示,我输入5,计算机打印5,

输入15,计算机打印15,234,打印234。这个问题。


当我处理2个数字a和b时出现问题。


案例2

#include< stdio.h>

int main()

{

int a,b,i;


for(i = 1; i< = 3; i ++)

{

scanf("%d,%d"& a,& b);

printf("%d,%d \ n", a,b);

}

返回0;

}

/ *结果

1 2

1,-858993460

2,-858993460

3 4

3, - 858993460

按任意键继续

* /


从上面的结果可以看出,当我输入1 2 ,我得到了奇怪的结果。我怀疑电脑正在打印空间。和输入密钥。

如何克服这个问题?


谢谢

Khoon。

Hope someone can help me to overcome this problem.
Case 1 is working perfectly working with one number entry.
Case 2 is the problem when I tried with 2 numbers entry.
Case 1.
#include <stdio.h>
int main ()
{
int a,i;

for (i=1;i<=3;i++)
{
scanf ("%d",&a);
printf ("%d\n",a);
}
return 0;
}
/* Result
5
5
15
15
234
234
Press any key to continue
*/
As the result shows, I enter 5 and computer prints 5,
enter 15 and computer prints 15 , 234 and prints 234. No problem with this.

The problem comes when I deal with 2 numbers, a and b.

Case 2
#include <stdio.h>
int main ()
{
int a,b,i;

for (i=1;i<=3;i++)
{
scanf ("%d,%d",&a,&b);
printf ("%d,%d\n",a,b);
}
return 0;
}
/* Result
1 2
1,-858993460
2,-858993460
3 4
3,-858993460
Press any key to continue
*/

As you can see from the above result, when I enter 1 2, I get weird result. I suspect the computer is printing "space" and "enter key".
How do I overcome this problem?

Thanks
Khoon.

推荐答案

Tiny Tim写道:
Tiny Tim wrote:
*希望有人能帮我解决这个问题。*
*案例1正在使用一个数字条目完美地工作。*
*案例2是我尝试输入2个数字时的问题。*
*案例1. *


[snip]

*案例2 *
* #include< stdio.h>
int main()
{
int a,b ,i;

for(i = 1; i< = 3; i ++)
{
scanf("%d,%d"& a,& b);
*Hope someone can help me to overcome this problem.*
*Case 1 is working perfectly working with one number entry.*
*Case 2 is the problem when I tried with 2 numbers entry.*
*Case 1. *
[snip]

*Case 2*
*#include <stdio.h>
int main ()
{
int a,b,i;

for (i=1;i<=3;i++)
{
scanf ("%d,%d",&a,&b);



scanf("%d%d",& a,& b);


Bj?rn

[snip]


scanf ("%d %d",&a,&b);

Bj?rn
[snip]




Tiny Tim写道:

Tiny Tim wrote:
希望有人可以帮助我克服这个问题。
案例1正在使用一个数字条目完美地工作。
案例2是我的问题案件1.
#include< stdio.h>
int main()
{... / int; i;

for(i = 1; i< = 3; i ++)
{
scanf("%d"& a);
printf("%d \ n",a);
}
返回0;
}
/ *结果
5
5
15 > 15
234
234
按任意键继续
* /
结果显示,我输入5并且电脑打印5,
输入15和计算机打印15,234和打印234.没有问题。

当我处理2个数字a和b时出现问题。

案例2 #include< stdio.h>
int main()
{a / b,i;

for(i = 1; i< = 3; i ++)
{x / scanf("%d,%d"& a,& b);
scanf("%d%d",& a,& b); printf("%d,%d \ n",a,b);
}
返回0;
}
/ *结果
1 2
1,-858993460
2,-858993460
3 4
3,-858993460
按任意键继续
* /
如何克服这个问题?

谢谢
Khoon。
Hope someone can help me to overcome this problem.
Case 1 is working perfectly working with one number entry.
Case 2 is the problem when I tried with 2 numbers entry.
Case 1.
#include <stdio.h>
int main ()
{
int a,i;

for (i=1;i<=3;i++)
{
scanf ("%d",&a);
printf ("%d\n",a);
}
return 0;
}
/* Result
5
5
15
15
234
234
Press any key to continue
*/
As the result shows, I enter 5 and computer prints 5,
enter 15 and computer prints 15 , 234 and prints 234. No problem with this.

The problem comes when I deal with 2 numbers, a and b.

Case 2
#include <stdio.h>
int main ()
{
int a,b,i;

for (i=1;i<=3;i++)
{
scanf ("%d,%d",&a,&b); scanf("%d%d", &a, &b); printf ("%d,%d\n",a,b);
}
return 0;
}
/* Result
1 2
1,-858993460
2,-858993460
3 4
3,-858993460
Press any key to continue
*/

As you can see from the above result, when I enter 1 2, I get weird result. I suspect the computer is printing "space" and "enter key".
How do I overcome this problem?

Thanks
Khoon.






Tiny Tim写道:
Tiny Tim wrote:
希望有人能帮我解决这个问题。
案例1正在完美地处理一个数字条目。
案例2是案例1
#include< stdio.h>
int main()
{
int a,i ;

for(i = 1; i< = 3; i ++)
{
scanf("%d",& a);
printf( %d \ n,a);
}
返回0;
}
/ *结果
5
5
15
15
234
按任意键继续
* /
结果显示,我输入5和电脑打印5,
当我处理2个数字a和b时出现问题。

案例2
#include< stdio.h>
int main()
{a / b,i;

for(i = 1; i< = 3; i ++)
{
scanf("%d,%d",& a,& b);
printf("%d,%d \ n",a,b);
}
返回0;
}
/ *结果
1 2
1,-858993460
2,-858993460
3 4 > 3,-858993460
按任意键继续
* /

从上面的结果可以看出,当我输入1 2时,我得到了奇怪的结果。我怀疑电脑正在打印空间。和输入密钥。
如何克服这个问题?
Hope someone can help me to overcome this problem.
Case 1 is working perfectly working with one number entry.
Case 2 is the problem when I tried with 2 numbers entry.
Case 1.
#include <stdio.h>
int main ()
{
int a,i;

for (i=1;i<=3;i++)
{
scanf ("%d",&a);
printf ("%d\n",a);
}
return 0;
}
/* Result
5
5
15
15
234
234
Press any key to continue
*/
As the result shows, I enter 5 and computer prints 5,
enter 15 and computer prints 15 , 234 and prints 234. No problem with this.

The problem comes when I deal with 2 numbers, a and b.

Case 2
#include <stdio.h>
int main ()
{
int a,b,i;

for (i=1;i<=3;i++)
{
scanf ("%d,%d",&a,&b);
printf ("%d,%d\n",a,b);
}
return 0;
}
/* Result
1 2
1,-858993460
2,-858993460
3 4
3,-858993460
Press any key to continue
*/

As you can see from the above result, when I enter 1 2, I get weird result. I suspect the computer is printing "space" and "enter key".
How do I overcome this problem?




不要输入1 2.这不是你编程的。相反,输入1,2

(即%d,%d)。


如果您打算输入1 2 do %d%d。



Don''t enter 1 2. That''s not what you programmed. Instead, enter 1,2
(which is "%d,%d").

If instead you intend to enter 1 2 do "%d %d".


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

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