| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 771 人关注过本帖
标题:[求助]怎样转换一个字符二维数组到一维数组~
只看楼主 加入收藏
gonua
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2006-4-16
收藏
 问题点数:0 回复次数:4 
[求助]怎样转换一个字符二维数组到一维数组~

怎样转换下面的二维数组到一维数组,然后输入数字,然后显示出输入数字在数组中相对应的词
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

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

搜索更多相关主题的帖子: 字符 
2007-03-24 21:42
neverTheSame
Rank: 3Rank: 3
来 自:江西农业大学
等 级:新手上路
威 望:9
帖 子:1511
专家分:0
注 册:2006-11-24
收藏
得分:0 

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


wap酷禾网(http://wap.),提供免费的、优质的、快捷的wap资源下载服务。
2007-03-24 21:53
gonua
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2006-4-16
收藏
得分:0 

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

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

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

2007-03-24 22:08
neverTheSame
Rank: 3Rank: 3
来 自:江西农业大学
等 级:新手上路
威 望:9
帖 子:1511
专家分:0
注 册:2006-11-24
收藏
得分: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."
};
再试一下.

wap酷禾网(http://wap.),提供免费的、优质的、快捷的wap资源下载服务。
2007-03-25 08:43
mp3aaa
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:2013
专家分:8
注 册:2006-2-15
收藏
得分:0 
commonWords[i]可以这样你自己试试就行

羊肉串 葡萄干 哈密瓜!!
2007-03-25 10:07
快速回复:[求助]怎样转换一个字符二维数组到一维数组~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050174 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved