zoukankan      html  css  js  c++  java
  • 代码

    #include "pch.h"
    #include "Shudu.h"
    //判断字符串是否只有数
    using namespace std;
    bool isnum(string s)
    {
        stringstream sin(s);
        double d;
        char c;
        if (!(sin >> d))
            return false;
        if (sin >> c)
            return false;
        else
            return true;
    }
    int main(int argc, char** argv)
    {
    
        int n;
        ofstream out("sudotiku.txt");
        //判断输入是否合法
        if (argc == 3)
        {
            if (strcmp(argv[1], "-c") == 0) //-c:生成的数独棋盘的数量
            {
                if (!isnum(argv[2]))
                {
                    cout << "Error input parameter" << endl << "Please re-enter an integer:";
                    cin >> n;
                }
                else
                {
                    n = atoi(argv[2]);
                }
            }
            else
            {
                cout << "Error input parameter" << endl << "Please re-enter an integer:";
                cin >> n;
            }
        }
        else
        {
            cout << "Error input parameter" << endl << "Please re-enter an integer:";
            cin >> n;
        }
        //判断输入的数字是否为0
        while (n == 0)
        {
            cout << "Error input parameter" << endl << "Please re-enter an integer:";
            cin >> n;
        }
        Shudu *sd = new Shudu[n];//动态生成n个数独
        srand(unsigned(time(NULL)));//产生随机数种子,防止每次产生的随机数相同
        for (int i = 0; i < n; i++)
        {
            sd[i].GenerateShudu();
            sd[i].PrintShudu();
            sd[i].WriteFile(out);
            cout << endl;
            out << endl;
        }
        delete[] sd;
        return 0;
    }
  • 相关阅读:
    软件测试面试题(一)
    测试面试题
    测试
    测试理论
    软件测试的认识
    理论知识
    H5页面的测试方式
    mysql数据库,linux,面试理论等
    登录设计点
    ATM境外取款测试点
  • 原文地址:https://www.cnblogs.com/xiaoyoushang/p/9790467.html
Copyright © 2011-2022 走看看