怎么了! [英] what is wrong!

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

问题描述

大家好,

我写了代码以获得以下输出:

1 2 3 4 5 6 7 8 9 10

2

3

4

5

6

7

8

9

10

1 2 3 4 5 6 7 8 9 10

2 1 3 4 5 6 7 8 9 10

1 3 2 4 5 6 7 8 9 10

3 2 4 1 5 6 7 8 9 10

2 4 1 5 3 6 7 8 9 10

4 1 5 3 6 2 7 8 9 10

1 5 3 6 2 7 4 8 9 10

5 3 6 2 7 4 8 1 9 10

3 6 2 7 4 8 1 9 5 10

6 2 7 4 8 1 9 5 10 3

但是,从代码收到的输出是不同的。

有一些错误,我感到很困惑。如果你这么多b $ b知道一些更好的建议并更正我的代码,

请出示。


tanx很多!


我写的代码如下:


#include< stdio.h>


int main(){

int a [10] [10];

int i,j,k,temp;


printf("输入(h = i; i< 10; i ++)

scanf("%d"& a [0] [$] $ i]);

printf(把整数9次来了);

for(i = 0; i< 9; i ++){

scanf("%d"& temp);


a [i + 1] [temp-1] = a [i] [0];


for(j = 0; j< temp-1; j ++)

a [i + 1] [j] = a [i] [j + 1 ];

for(j = temp; j< 10; j ++)

a [i + 1] [j] = a [i] [j];


}

for(i = 0; i< 10; i ++){

for(j = 0; j< 10; j ++ ){

printf("%d",a [i] [j]);

}

printf(" \\ \\ n");

返回0;

}

}


-

John

Hi all,
I wrote the code to get the following output:
1 2 3 4 5 6 7 8 9 10
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10
2 1 3 4 5 6 7 8 9 10
1 3 2 4 5 6 7 8 9 10
3 2 4 1 5 6 7 8 9 10
2 4 1 5 3 6 7 8 9 10
4 1 5 3 6 2 7 8 9 10
1 5 3 6 2 7 4 8 9 10
5 3 6 2 7 4 8 1 9 10
3 6 2 7 4 8 1 9 5 10
6 2 7 4 8 1 9 5 10 3
but,the output received from the code is different.
there is some mistake and I got confusion on.if you
know some better advice and correction to my code,
please show it.

tanx a lot!

the code wrote by me is as below:

#include<stdio.h>

int main(){
int a[10][10];
int i,j,k,temp;

printf("input the integer\n");
for(i=0;i<10;i++)
scanf("%d",&a[0][i]);
printf("put the integer 9times\n");
for(i=0;i<9;i++){
scanf("%d",&temp);

a[i+1][temp-1] = a[i][0];

for(j=0;j<temp-1;j++)
a[i+1][j] = a[i][j+1];
for(j=temp;j<10;j++)
a[i+1][j] = a[i][j];

}
for(i=0;i<10;i++){
for(j=0;j<10;j++){
printf("%d ",a[i][j]);
}
printf("\n");
return 0;
}
}

--
John

推荐答案



" John" < GH ***** @ fsmail.net>在消息中写道

新闻:11 ********************* @ c13g2000cwb.googlegro ups.com ...

"John" <gh*****@fsmail.net> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
大家好,
我写了代码以获得以下输出:
1 2 3 4 5 6 7 8 9 10
2
3
4
5
6
8
9
10
1 2 3 4 5 6 7 8 9 10
2 1 3 4 5 6 7 8 9 10
1 3 2 4 5 6 7 8 9 10
3 2 4 1 5 6 7 8 9 10
2 4 1 5 3 6 7 8 9 10
4 1 5 3 6 2 7 8 9 10
1 5 3 6 2 7 4 8 9 10
5 3 6 2 7 4 8 1 9 10
3 6 2 7 4 8 1 9 5 10
6 2 7 4 8 1 9 5 10 3

但是,从代码收到的输出是不同的。
有一些错误,我感到困惑如果你对我的代码知道一些更好的建议和更正,请显示它。
Hi all,
I wrote the code to get the following output:
1 2 3 4 5 6 7 8 9 10
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10
2 1 3 4 5 6 7 8 9 10
1 3 2 4 5 6 7 8 9 10
3 2 4 1 5 6 7 8 9 10
2 4 1 5 3 6 7 8 9 10
4 1 5 3 6 2 7 8 9 10
1 5 3 6 2 7 4 8 9 10
5 3 6 2 7 4 8 1 9 10
3 6 2 7 4 8 1 9 5 10
6 2 7 4 8 1 9 5 10 3
but,the output received from the code is different.
there is some mistake and I got confusion on.if you
know some better advice and correction to my code,
please show it.




请准确描述该程序的内容到了
呢。我不会想弄清楚''模式'是什么原因

应该是什么。


你说的方式,我的解决方案是

简单地''硬编码''那些线并输出它们


例如:


put(1 2 3 4 5 6 7 8 9 10);





(但我怀疑'这就是'所需要的'。


另外请学习缩进你的代码。


-Mike


亲爱的Mike,


我尝试声明一个尺寸为10×10的二维数组

首先。之后我会把b> b的整数读成[0] [0]到[0]] 9]。之后,我是

去重复由整数序列指定的

插入约9次,并将

a [1]的

结果存储到[9] 。

在决赛中,我尝试打印阵列,就像我指向我的第一个

帖子一样出局了t。


感谢

Dear Mike,

I try to declare a two dimensional array with a size 10 by 10 at
first.after that I am
going to read the integers into a[0][0] to a[0]]9] .after that,I am
going to repeat the
insertion specified by an integer sequence about 9 times, and store the
results from
a[1] to a[9].
at the final,I try to print the array same as I pointed to my first
post as an out put.

thanks


2005年1月8日07:20:31 -0800,John < GH ***** @ fsmail.net>写道:


我注意到的一个错误是返回语句在循环内部而不是跟随它:
On 8 Jan 2005 07:20:31 -0800, "John" <gh*****@fsmail.net> wrote:

One mistake I notice is that the return statement is inside
the loop instead of following it:
for(i = 0; i< 10; i ++){
for(j = 0; j< 10; j ++){
printf("%d",a [i] [ j]);
}
printf(" \ n");
返回0;
}
for(i=0;i<10;i++){
for(j=0;j<10;j++){
printf("%d ",a[i][j]);
}
printf("\n");
return 0;
}




尼克。



Nick.


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

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