poj2328 Guessing Game

#include<iostream>
#include<string>
#include<vector>
using namespace std;

struct Info//guess信息储存 
{
       int num;
       string guess;
};
vector<Info> v;//储存信息的结构体! 

int main()
{
    int size, i;
    Info info, tmp;
    v.clear();
    bool flag;
    while (cin >> info.num){
          if (info.num == 0)  break;
          cin.get();
          getline(cin, info.guess);
          //如果输入的字符是“right on”的时候就处理,否则就输入到容器v中保存! 
          if (info.guess == "right on"){
              size = v.size();
              flag = false;
              for (i = 0; i < size; i++){
                  if ((v[i].num > info.num && v[i].guess == "too high") || (v[i].num < info.num && v[i].guess == "too low"))
                      continue;
                  else{
                       flag = true;
                       break;
                  }
              }
              if (flag)
                  cout << "Stan is dishonest" << endl;
              else
                  cout << "Stan may be honest" << endl;
              v.clear();
          }
          else   v.push_back(info);
    }
    
    system("pause");
}

你可能感兴趣的:(String,System)