| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 668 人关注过本帖
标题:strcmp二维数组字典程序纠错
取消只看楼主 加入收藏
Timber
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2010-1-31
结帖率:71.43%
收藏
 问题点数:0 回复次数:2 
strcmp二维数组字典程序纠错
Write a program that implements finnish-english dictionary
using a two dimensional array of char pointers. The array row shall
contain first english word and then finnish word.

hint:
char *dict[??][2] = { ??? };

The words known by the program are set in the array initialization.

Program asks user to enter a word (in english of finnsh) and then searches
the dictionary for that word. If the word is found it diplays
the word in both languages. If word is not found user is notified that word is
not in the dictionary.

hint: use strcmp

User exits the program by entering a line which contains
a single dot.

You can use your own language instead of finnish if you wish.

Use functions to divide your program to smaller units.

------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

int main()
{
    char *word;
    int i;
    char *give[2][2]={{"nice","kaunis"},{"ugly","ruma"}};
    printf("please enter a word:");
    scanf("%s",word);
    printf("\n");
    for (i=0;i<=2;i++)
    {

        if (!strcmp(word,give[i][0]))
        {
            printf("%s   %s\n",word,give[i][1]);
            break;
        }
    }

    return 0;
}

[ 本帖最后由 Timber 于 2010-4-22 15:11 编辑 ]
搜索更多相关主题的帖子: dictionary 字典 word 
2010-04-22 14:49
Timber
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2010-1-31
收藏
得分:0 
回复 2楼 ychf890225
请问怎么初始化指向啊,我是菜鸟,不要意思

But here I am
2010-04-22 14:57
Timber
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2010-1-31
收藏
得分:0 
自顶。。就这么沉了。。

But here I am
2010-04-23 15:30
快速回复:strcmp二维数组字典程序纠错
数据加载中...
 
   



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

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