|
I started to learn c++ from a humble beginning a month ago.
I often have many simple questions here.
My many c++ skills is from the friends who is from linuxsir.
So, I think, I want to say thanks here.
I want to say thanks by c++,
- #include<iostream>
- #include<string>
- using namespace std;
- const int size=11;
- void min ();
- int main ()
- {
- cout<<"First, please let me say: best regards to you."
- <<"The program is run to guess a clase that conains eleven letter. Only the first one is capital."
- <<"You could type eleven letters followed by enter."
- <<"Okay, now, give it a go->:"<<endl;
- min ();
- }
- void min () {
- char input[size];
- char result[]="Best regards";
- char c;
- string s;
- while (true) {
- for (int i=0; i<size; i++) //initialize the array
- cin>>input[i];
- for (int i=0; i<size; i++) //compare with the result
- if (input[i]==result[i])
- cout<<"The "<<i<<"th letter is good."<<endl;
- else
- cout<<"Sorry for the "<<i<<"th letter."<<endl;
- cin>>s; //the cin is used to filter extra letters
- cout<<"Do you want ot try again, yet? y for yes, other keys for no."<<endl;
- cin>>c;
- if (c=='y')
- continue;
- else
- break;
- }
- }
复制代码 |
|