fqy131314

C++——第6节 代码世界中的传送阵:goto语句

传送阵:

 demo:

#include <iostream>

#include <Windows.h>

#include <string>

using namespace std;

int main(void) {

       string ret;

       for (int i=0; i<3; i++) {

              cout << "开始第" << i+1 << "次相亲..." << endl;

              cout << "你喜欢打王者吗?" << endl;

              cin >> ret;

              if (ret != "yes") {

                     continue;

              }

              cout << "加个微信吧..." << endl;

              cout << "我中意你, 你中意我吗?" << endl;

              cin >> ret;

              if  (ret == "yes") {

                     goto happy;

              }

       }

       system("pause");

       return 0;

happy:

       cout << "开启浪漫之旅..." << endl;

       system("pause");

       return 0;

}

posted on 2022-10-18 09:05  会飞的鱼-blog  阅读(16)  评论(0)    收藏  举报  来源

导航