首页
社区
课程
招聘
[旧帖] [求助]单步执行循环和直接执行结果不一样? 0.00雪花
发表于: 2008-1-5 11:34 2627

[旧帖] [求助]单步执行循环和直接执行结果不一样? 0.00雪花

2008-1-5 11:34
2627
CString  strTemp1;
        CString  strTemp2;
        CString  strTemp3;
        CString   result;
        char string[25];
        int min;
        int max;
        int numble;
        int looptimes;
        AfxGetMainWnd()->GetDlgItem(IDC_EDIT1)->GetWindowText(strTem1);
        AfxGetMainWnd()->GetDlgItem(IDC_EDIT2)->GetWindowText(strTem2);
        AfxGetMainWnd()->GetDlgItem(IDC_EDIT3)->GetWindowText(strTem3);
        numble =atoi(strTemp1.GetBuffer(strTemp1.GetLength()));  
        min=atoi(strTemp2.GetBuffer(strTemp2.GetLength()));
        max=atoi(strTemp3.GetBuffer(strTemp3.GetLength()));
        int* array;
        array = new int [numble];
        for(looptimes=0;looptimes<numble;looptimes++)
        {       
                srand( (unsigned)time( NULL ) );
                int N =  min+rand()%(max-min);  
                *(array+looptimes)=N;
                result+=itoa(N, string, 10);
                result+=" ";
               

        }
        MessageBox(result);
如果单步执行循环的话,弹出的消息框是不同的数字,但是直接执行的话,显示的一定是相同的数字,这是为什么啊?哪位帮忙看1下啊

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//