当前位置: 代码迷 >> C语言 >> [求助]怎样转换一个字符二维数组到一维数组~
  详细解决方案

[求助]怎样转换一个字符二维数组到一维数组~

热度:336   发布时间:2007-03-24 21:42:46.0
[求助]怎样转换一个字符二维数组到一维数组~

怎样转换下面的二维数组到一维数组,然后输入数字,然后显示出输入数字在数组中相对应的词
char commonWords[13][60] =
{"C is a structured, procedural programming",
"language that has been widely used both for",
"operating systems and applications and that has",
"had a wide following in the academic community.",
"Many versions of Unix-based operating systems are",
"written in C. With the increasing popularity of",
"object-oriented programming, C is being rapidly",
"replaced as "the" programming language by C++,",
"a superset of the C language that uses an",
"entirely different set of programming concepts,",
"and by Java, a language similar to but simpler",
"than C++, that was designed for use in",
"distributed networks."
};

Enter the number : 5
Word at that index: programming

请各位帮帮我,我写出来的程序总是显示乱码,要不就出错,我都郁闷了。。。

搜索更多相关的解决方案: 字符  

----------------解决方案--------------------------------------------------------

可以不用其它数组,
可以这样做:
int i;
printf("Enter the number : ");
scanf("%d",&i);
printf("%s",commonWords[i]);


----------------解决方案--------------------------------------------------------

我主要想知道如何转换这个二维数组到一维数组。。。。

ps: 我刚试了楼上回复的,出来的答案是错的。。。

[此贴子已经被作者于2007-3-24 22:09:28编辑过]


----------------解决方案--------------------------------------------------------
char commonWords[13][60] =
{"C is a structured, procedural programming",
"language that has been widely used both for",
"operating systems and applications and that has",
"had a wide following in the academic community.",
"Many versions of Unix-based operating systems are",
"written in C. With the increasing popularity of",
"object-oriented programming, C is being rapidly",
"replaced as \"the\" programming language by C++,",
"a superset of the C language that uses an",
"entirely different set of programming concepts,",
"and by Java, a language similar to but simpler",
"than C++, that was designed for use in",
"distributed networks."
};
再试一下.
----------------解决方案--------------------------------------------------------
commonWords[i]可以这样你自己试试就行
----------------解决方案--------------------------------------------------------
  相关解决方案