m0_65669447
2021-12-23 11:44
采纳率: 100%
浏览 30

为啥用visual c++6.0运行不了

#include "stdafx.h"
#include
#include
#include
using namespace std;

//生成两个随机数
int num(int &a, int &b)
{
int a1, b1;
do
{
a1 = rand() % 50;
b1 = rand() % 50;
} while (!(a1 + b1 >= 0 && a1 + b1 <= 50 && a1 - b1 >= 0 && a1 - b1 <= 50));
a = a1, b = b1;
return a;
return b;
}

int _tmain(int argc, _TCHAR* argv[])
{
srand(time(NULL));//时间,保证每次的随机数不同
cout << "-----------------------高考试题----------------------" << endl;
int a, b, y,e,ans,t=1,sum=0,cnt=0;
while (t <= 10)
{
cout << "NO." << t << endl;
e = rand() % 2 + 1;//加减号判断
num(a, b);
while (cnt <= 3)//输入次数的判断
{
if (e == 1)//1为+号
{
cout << a << "+" << b << "=";
cin >> ans;
if (a + b == ans)
{
cout << "答对啦" << endl;
if (cnt == 0)sum += 10;//进行分数叠加
if (cnt == 1)sum += 7;
if (cnt == 2)sum += 5;
if (cnt == 3)sum += 0;
break;
}
else{
cnt++;//回答次数叠加
cout << "错了!" << endl;
if (cnt == 3)
{
cout << "答案:" << a + b << endl;
if (cnt == 0)sum += 10;
if (cnt == 1)sum += 7;
if (cnt == 2)sum += 5;
if (cnt == 3)sum += 0;
break;
}
}
}
else if (e==2)//2为减号
{
cout << a << "-" << b << "=";
cin >> ans;
if (a - b == ans)
{
cout << "答对啦" << endl;
if (cnt == 0)sum += 10;
if (cnt == 1)sum += 7;
if (cnt == 2)sum += 5;
if (cnt == 3)sum += 0;
break;
}
else
{
cnt++;
cout << "错了!" << endl;
if (cnt == 3)
{
cout << "答案:" << a - b << endl;
sum += 0;
break;
}
}
}
}

    if (cnt == 0)cout << "本题得10分" << '\n';
    if (cnt == 1)cout << "本题得7分" << '\n';  
    if (cnt == 2)cout << "本题得5分" << '\n';
    if (cnt == 3)cout << "本题得0分" << '\n';
    t++;
    cnt = 0;
}
cout << "------------------------考试结束------------------------" << endl;
cout << "您的总分为:" << sum<<endl;
int x;
x = sum / 10;
switch (x)
{
case(10) : cout << "SMART!" << endl; break;
case(9) : cout << "SMART!" << endl; break;
case(8) : cout << "GOOD!" << endl; break;
case(7) : cout << "OK" << endl; break;
default:cout << "TRY AGAIN" << endl; break;
}
cin.get();
cin.get();
return 0;
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • Admini$trat0r 2021-12-23 11:51
    最佳回答

    你这是win32控制台应用程序啊

    #include "stdafx.h"  
     
     
    int _tmain(int argc, _TCHAR* argv[])  
    {  
        return 0;  
    }  
    

    改为

    #include  <stdio.h>  
     
    int main()  
    {  
           return 0;  
    } 
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题