两道c语言的题

来源:百度知道 编辑:UC知道 时间:2024/09/23 10:52:17
1。先为C++中的所有的关键字,建立一张关键字表,查找随机输入的英文单词是否在关键字表中。

2. 使用带参数的宏,从3个随机数中找出最大的数并输出。

各位打下帮帮忙谢了

#include<iostream>
#include<cstdlib>
using namespace std;
typedef struct _str{
char *key;
}str;
void main()
{
str arr[5];
arr[0].key="aa";
arr[1].key="bb";
arr[2].key="cc";
arr[3].key="dd";
arr[4].key="ee";
char *temp=new char;
cin>>temp;
int i;
for(i=0;i<5;i++)
{
if(0==strcmp(temp,arr[i].key))
{
cout<<"OK!Find it in:arr["<<i<<"]"<<endl;
break;
}
}
cout<<"NOT FOUND!!"<<endl;
cout<<"Rondom Num:"<<endl;
int a[3],max;
for(i=0;i<3;i++)
{
a[i]=(rand()%20);
cout<<a[i]<<" ";
}
max=(a[0]>a[1])?a[0]:a[1];
max=(max>a[2])?max:a[2];
cout<<endl<<"The max num is:"<<ma