/* Note:Your choice is C IDE */
#include <stdio.h>
#include <stdbool.h>
struct entry
{
char word[15];
char definition[50];
};
bool equalStrings(const char s1[],const char s2[])
{
int i=0;
bool areEqual;
while(s1[i]==s2[i] && s1[i]!='\0' && s2[i]!='\0')
++i;
if(s1[i]=='\0' && s2[i]!='\0')
areEqual=true;
else
areEqual=false;
return areEqual;
}
int lookup(const struct entry dictionary[],const char search[],const int entries)
{
int i;
bool equalStrings(const char s1[],const char s2[]);
for(i=0;i<entries;++i)
if(equalStrings(search,dictionary[i].word))
return i;
return -1;
}
void main()
{
const struct entry dictionary[100]=
{{"aardvark","a burrowing African mammal"},
{"abyss","a bottomless pit"},
{"acumen","mentally sharp;keen"},
{"addle","to become confused"},
{"aerie","a high nest"},
{"affix","to append;attach"},
{"agar","a jelly made from seaweed"},
{"ahoy","a nautical call of greeting"},
{"aigrette","an ornamental cluster of feathers"},
{"ajar","partially opened"}};
char word[10];
int entries=10;
int entry;
int lookup(const struct entry dictionary[],const char search[],const int entries);
printf("Enter word:");
scanf("%14s",word);
entry=lookup(dictionary,word,entries);
if(entry!=-1)
printf("%s\n",dictionary[entry].definition);
else
printf("Sorry,the word %s is not in my dictionary.\n",word);
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
适合初学者的五十道基础编程题
共78个文件
c:53个
pch:2个
dsp:2个
需积分: 50 5 下载量 55 浏览量
2008-09-14
11:19:06
上传
评论 1
收藏 245KB RAR 举报
温馨提示
初学者必看的五十道程序算法题,代码来自多本权威丛书
资源推荐
资源详情
资源评论
收起资源包目录
C Exercise.rar (78个子文件)
C Exercise
c8_14.c 1KB
倍约.c 298B
10.2.c 336B
c5_6.c 576B
c2_2.c 322B
lookupdic.c 1KB
c8_3.c 363B
aaa.c 316B
Release
vc60.idb 25KB
cGCD.pch 174KB
cGCD.obj 1KB
cGCD.exe 44KB
c7_5.c 405B
10.3.c 457B
cGCD.mak 4KB
10.4.c 513B
c6_2.c 414B
c8_16.c 554B
cGCD.dsw 533B
Josephus算法.c 656B
求素数.c 600B
1!_2~1exe 164KB
c8_8.c 435B
c7_3.c 282B
erfenfa.c 439B
c8_2.c 898B
c13_3.c 558B
lookup.c 1KB
c13_2.c 525B
cGCD.ncb 33KB
1!_2~1obj 2KB
cGCD.dsp 3KB
c8_9.c 597B
6.13.c 448B
sqlist.c 996B
10.6.c 240B
zhncsh1.c 333B
f1.c 675B
Debug
vc60.pdb 44KB
cGCD.pdb 433KB
vc60.idb 33KB
cGCD.ilk 181KB
cGCD.pch 171KB
cGCD.obj 3KB
cGCD.exe 180KB
问号.c 203B
c8_5.c 399B
array_inv.c 771B
c5_8fu.c 797B
cGCD.c 284B
lookupdic.dsw 543B
123.c 299B
c7_2.c 592B
lookupdic.dsp 3KB
10.1.c 236B
c6_10.c 194B
c8_18.c 647B
cGCD.opt 48KB
c5_24.c 176B
12.c 300B
s209.c 753B
p66.c 899B
c8_5fu.c 373B
c13_1.c 346B
10.8.c 505B
cGCD.dep 80B
lookupdic.ncb 33KB
yingwenzimu.c 454B
10.9.c 415B
10.5.c 657B
lookupdic.opt 48KB
s209fu.c 1KB
递归算法1.c 580B
c6_4.c 205B
cGCD.plg 746B
1!+2!+…+20!.c 170B
lookupdic.plg 2KB
c5_8.c 667B
共 78 条
- 1
资源评论
天下无人不识君
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功