LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 763|回复: 2

Best regards to you.

[复制链接]
发表于 2003-9-23 10:38:32 | 显示全部楼层 |阅读模式
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++,

  1. #include<iostream>
  2. #include<string>
  3. using namespace std;

  4. const int size=11;
  5. void min ();
  6. int main ()
  7. {
  8.    cout<<"First, please let me say: best regards to you."
  9.        <<"The program is run to guess a clase that conains eleven letter. Only the first one is capital."
  10.        <<"You could type eleven letters followed by enter."
  11.        <<"Okay, now, give it a go->:"<<endl;
  12.    min ();
  13. }

  14. void min () {
  15.    char input[size];
  16.    char result[]="Best regards";
  17.    char c;
  18.    string s;
  19.    while (true) {
  20.       for (int i=0; i<size; i++) //initialize the array
  21.          cin>>input[i];
  22.       for (int i=0; i<size; i++) //compare with the result
  23.          if (input[i]==result[i])
  24.             cout<<"The "<<i<<"th letter is good."<<endl;
  25.          else
  26.             cout<<"Sorry for the "<<i<<"th letter."<<endl;
  27.       cin>>s; //the cin is used to filter extra letters
  28.       cout<<"Do you want ot try again, yet? y for yes, other keys for no."<<endl;
  29.       cin>>c;
  30.       if (c=='y')
  31.          continue;
  32.       else
  33.          break;
  34.    }
  35. }
复制代码
发表于 2003-9-23 11:02:34 | 显示全部楼层
太客气了,
大家都是兄弟嘛
 楼主| 发表于 2003-9-23 11:24:13 | 显示全部楼层
现在发现有一处不合适:
cin>>s; //the cin is used to filter extra letters
这样的话,用户还要另外再输入。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表