65,210
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
bool findDigit(const char* text, const char *model)
{
const char *first=&text[0], *end=&text[strlen(text)+1];
for(int i=0;i<strlen(model);i++)
{
first = find(first,end,model[i]);
if(first==end)
return false;
}
return true;
}
void toUpper(char &a)
{
a = toupper(a);
}
int main()
{
int b = 1;
char* example[9] = {"ONE","TWO","THERE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};
char* a = new char[100];
cout<<"input the word \"quit\" to quit the program."<<endl;
do
{
bool match = false;
cout<<"input word:"<<endl;
cin>>a;
for_each(&a[0],&a[strlen(a)],toUpper);
for(int i=0;i<9;i++)
{
if(findDigit(a,example[i]))
{
cout<<a<<endl<<i+1<<endl;
match = true;
}
}
if(!match)
cout<<a<<endl<<"NO"<<endl;
}while(strcmp(a,"QUIT"));
return 0;
}
把题目写出来先