输出混乱 [英] Confusion on output

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

问题描述

大家好,

我在以下问题上做了解决方案,但没有想要的输出是

实现。如果你知道某种方式,请告诉我它的评论。

---------------------------------------- -------------

(声明一个二维数组a的大小为10乘以10和

将10个整数声明为[0] [0]到[0] [9]。然后重复由整数序列指定的

插入9次,并且

存储[a]的结果1]到a [9]。最后,打印阵列。

输出示例:

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)

-------------------------------- -----------------------


我做了:


#include< stdio.h>


int main()

{

int a [10] [10] ;

int i,j,k;

int x;

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

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


}


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

for(j = 0; j< i + 1; j ++){

x = a [i] [j];

a [i] [j] = a [i] [j];

a [i] [j] = x;

for(k = 0; k <10; k ++)printf("%d",a [j] [k]);

printf( " \ n");

}

printf(" \ n");

}

返回0;

}

但输出完全不同。

tanx提前

hi all,
I did the solution on the following question,but no desired output is
acheived.if you know some way on,please show me with its comments.
-----------------------------------------------------
(Declare a two-dimensional array"a" of size 10 by 10 and
read 10 integers into a[0][0] to a[0][9].Then repeat the
insertion specified by an integer sequence nine times,and
store the results from a[1] to a[9].Finally,print the array.
Output Example:
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)
-------------------------------------------------------

I did as :

#include <stdio.h>

int main()
{
int a[10][10];
int i,j,k;
int x;
for(i=0; i<10; i++){
for(j=0; j<10; j++) a[i][j]=j+1;

}

for(i=0; i<10; i++){
for(j=0; j<i+1; j++){
x= a[i][j];
a[i][j] = a[i][j];
a[i][j]=x;
for(k=0; k<10; k++)printf("%d", a[j][k]);
printf("\n");
}
printf("\n");
}
return 0;
}
but,the output is compeletly different.
tanx in advance

推荐答案



" engartte" < NA ***** @ hotmail.com>在消息中写道

news:11 ********************** @ c13g2000cwb.googlegr oups.com ...

"engartte" <na*****@hotmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
大家好,
我在下面的问题上做了解决方案,但没有想要的输出。如果你知道某些方法,请告诉我它的评论。
- -------------------------------------------------- -
(声明一个二维数组a,大小为10×10,将10个整数读成[0] [0]到[0] [9]。然后重复
由整数序列指定9次插入,并将结果从[1]存储到[9]。最后,打印数组。
输出示例:
1 2 3 4 5 6 7 8 9 10
2
4
5
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)
---------------------------------------------- ---------

我做了:

#include< stdio.h>

int main()
{
int a [10] [10];
int i,j,k;
int x;
for(i = 0; I< 10; i ++){
for(j = 0; j< 10; j ++)a [i] [j] = j + 1;

}

i = 0; i< 10; i ++){
for(j = 0; j< i + 1; j ++){
x = a [i] [j];
a [ i] [j] = a [i] [j];
a [i] [j] = x;
for(k = 0; k <10; k ++)printf("%d" ;,[j] [k]);
printf(" \ n");
}
printf(" \ n");
}
返回0;
}

但是,输出完全不同。
tanx提前
hi all,
I did the solution on the following question,but no desired output is
acheived.if you know some way on,please show me with its comments.
-----------------------------------------------------
(Declare a two-dimensional array"a" of size 10 by 10 and
read 10 integers into a[0][0] to a[0][9].Then repeat the
insertion specified by an integer sequence nine times,and
store the results from a[1] to a[9].Finally,print the array.
Output Example:
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)
-------------------------------------------------------

I did as :

#include <stdio.h>

int main()
{
int a[10][10];
int i,j,k;
int x;
for(i=0; i<10; i++){
for(j=0; j<10; j++) a[i][j]=j+1;

}

for(i=0; i<10; i++){
for(j=0; j<i+1; j++){
x= a[i][j];
a[i][j] = a[i][j];
a[i][j]=x;
for(k=0; k<10; k++)printf("%d", a[j][k]);
printf("\n");
}
printf("\n");
}
return 0;
}
but,the output is compeletly different.
tanx in advance




你真的想用二维阵列存储什么?

你能说清楚吗,它是一个预定义的模式/序列吗?


-Neo



What you actually want to store in 2-D array?
Would you make it clear, is it a predefined pattern/sequence?

-Neo


engartte写道:
engartte wrote:
我在下面的问题上做了解决方案,但没有想要的输出是
实现的。如果你知道某种方式,请告诉我它的评论。
-------------------------------------- ---------------
(声明一个二维数组a,大小为10乘以10,并将10个整数读成[0] [0 ]到[0] [9]。然后重复由整数序列指定的
插入九次,并将结果从[1]存储到[9]。最后,打印数组。
输出示例:
1 2 3 4 5 6 7 8 9 10
2
3
5
6 > 7
8
9
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)
-------------------------------------- -----------------
I did the solution on the following question,but no desired output is
acheived.if you know some way on,please show me with its comments.
-----------------------------------------------------
(Declare a two-dimensional array"a" of size 10 by 10 and
read 10 integers into a[0][0] to a[0][9].Then repeat the
insertion specified by an integer sequence nine times,and
store the results from a[1] to a[9].Finally,print the array.
Output Example:
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)
-------------------------------------------------------




#include< stdio.h>


void println(int a [10])

{

int i = 10;

do printf("%d" ,* a ++); while( - i&& printf(""));

printf(" \ n");

}


int main()

{

int a [10] [10] = {1,2,3,4,5,6, 7,8,9,10};

int i,j,k;


println(a [0]);

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

{

printf("%d \ n",k = a [0] [i]);

--k;

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

a [i] [j] = a [i-1] [0];

while(++ j< 10)a [i] [j] = a [i-1] [j];

}

for(i = 0; i< 10; ++ i)println(a [i]);

返回0;

}


/ *随意添加更多评论对此。 * /



#include <stdio.h>

void println(int a[10])
{
int i = 10;
do printf("%d", *a++); while (--i && printf(" "));
printf("\n");
}

int main()
{
int a[10][10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int i, j, k;

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

/* Feel free to add more comments to this. */


亲爱的Dietmar Schindler,

非常感谢解决方案。但是,如果可能的话,请告诉我更多关于

println

以及此程序的操作。对我来说,使用

术语println是新的因为我是C和阵列的新手。


提前谢谢


engartte
Dear Dietmar Schindler,
Thanks a lot for solution.but,If possible,please tell me more about
"println"
and the operation of this program.as for me, the use of the
term"println" is
new because I am new with C and array.

Thanks in advance

engartte


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

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