• c++ 实验二


    #include<iostream>
    using namespace std;
    int main() {
        char n;
            cout<<"Menu:A(dd) D(elete) S(ort) Q(uit),select one:";
            cin>>n;
            if(n=='A'){
            cout<<"数据已经增加。";
            }
            else if(n=='D'){
            cout<<"数据已经删除。";
            }
            else if(n=='S'){
            cout<<"数据已经排序。";
            }
            else if(n=='Q'){
            exit (0);
            }
        return 0;
    }          

    #include<iostream>
    using namespace std;
    int main() {
        char n;
        cout << "Menu:A(dd) D(elete) S(ort) Q(uit),select one:";
        cin >> n;
        switch(n){
        case'A':
            cout << "数据已经增加。";
            break;
        case'D':
            cout << "数据已经删除。";
            break;
        case'S':
            cout << "数据已经排序。";
            break;
        case'Q':
            break;
        }
        return 0;
    }

    #include<iostream>
    using namespace std;
    int main() {
        int n = 1,i = 0, j = 1;
        while (n <= 100) {
            i = 0;
            j = 1;//复位
            while (j < n)
            {
                if (n%j == 0)
                    i++;
                j++;
            }
            if (i == 1)
                cout << n << endl;
            n++;
        }
        return 0;
    }

    #include<iostream>
    using namespace std;
    int main() {
        int n = 1,i = 0, j = 1;
        do {
            i = 0;
            j = 1;//复位
            do {
                if (n%j == 0)
                    i++;
                j++;
            } while (j < n);
            if (i == 1)
                cout << n << endl;
            n++;
        } while (n <= 100);
        return 0;
    }

    #include<iostream>
    using namespace std;
    int main() {
        int n, i = 0,j;
        for (n = 1; n <= 100; n++) {
            i = 0;//复位
            for (j = 1; j < n; j++)
                if (n%j == 0)
                    i++;
            if (i == 1)
                cout << n << endl;
        }
        return 0;
    }

    #include<iostream>
    #include<cstdlib>
    using namespace std;
    int main() {
        int n,answer,i,t=1;
        cout << "输入一个随机数字开始游戏:" << endl;
        cin >>i ;
        srand(i);
        answer = rand() % 100;
        while(t=1){
            cout << "输入一个1-100间的数字:" << endl;
            cin >> n;
            if (n < answer) {
                cout << "你猜的太小了。" << endl;
                continue;
            }
            if (n > answer) {
                cout << "你猜的太大了。" << endl;
                continue;
            }
            if (n = answer) {
                cout << "恭喜你答对了。";
                break;
            }
        }
        system("pause");//为了截个图加的-_-
        return 0;
    }

    #include<iostream>
    #include<cstdlib>
    using namespace std;
    int main() {
        int n,answer,i,t=1;
        cout << "输入一个随机数字开始游戏:" << endl;
        cin >>i ;
        srand(i);
        answer = rand() % 100;
        do{
            cout << "输入一个1-100间的数字:" << endl;
            cin >> n;
            if (n < answer) {
                cout << "你猜的太小了。" << endl;
                continue;
            }
            if (n > answer) {
                cout << "你猜的太大了。" << endl;
                continue;
            }
            if (n = answer) {
                cout << "恭喜你答对了。";
                break;
            }
        }while (t = 1);
        system("pause");//为了截个图加的-_-
        return 0;
    }

    #include<iostream>
    using namespace std;
    int main() {
        int i, j, k,num=0;
        char color[5][7] = { "Red","Yellow","Blue","White","Black" };
        for(i=0;i<=5;i++){
            for (j = i+1; j < 5; j++) {
                for (k = j+1; k < 5; k++) {
                    if (i != j && i != k && j != k)
                        num++;
                }
            }
        }
        cout << num;
        system("pause");
        return 0;
    }

  • 相关阅读:
    C语言复习---杨辉三角打印
    C语言复习---获取矩阵的对角和
    C语言复习---选择法排序
    C语言复习---用筛选法求100之内的素数
    C语言复习---比赛问题
    C语言复习---打印菱形
    建立一个node.js服务器(使用express搭建第一个Web环境)
    nodejs小问题:express不是内部或外部命令
    使用express搭建第一个Web应用【Node.js初学】
    Node.js 相关资料网站汇总
  • 原文地址:https://www.cnblogs.com/nuo26/p/8642004.html
Copyright © 2020-2023  润新知