运行时初始化失败 [英] run-time initialization failure
问题描述
您好
我是C ++的新手。
我正在写作这个程序让学生输入他们的成绩,程序的输出会显示成绩,总分和平均分。当我朗读我的程序时,我收到以下消息
#include
< iostream>
#include
< math.h>
使用
命名空间
std;
namespace std;
int
main()
main()
{
int
test1; //用户输入
int test1; // input by user
int
test2; //用户输入
int test2; // input by user
int
test3; //用户输入
int test3; // input by user
int
average; //由程序计算
int average; // computed by the program
int
total; //变量,其中总计将存储
cout<<
cout<<
"输入test1 grade" << endl;
"enter test1 grade"<<endl;
cin>> test1;
cin>>test1;
cout<<
cout<<
"输入test2 grade" << endl;
"enter test2 grade"<<endl;
cin>> test2;
cin>>test2;
cout<<
cout<<
"输入test3 grade" << endl;
"enter test3 grade"<<endl;
cin>> test3;
cin>>test3;
cout<<
cout<<
" +++++++++++++++++++++++++++ << endl;
"++++++++++++++++"<<endl;
cout<<
cout<<
" *** Test1 =" << test1<< endl;
"*** Test1="<<test1<<endl;
cout<<
cout<<
" *** Test2 =" << test2<< endl;
"*** Test2="<<test2<<endl;
cout<<
cout<<
" *** Test3 =" << test3<< endl;
"*** Test3="<<test3<<endl;
cout<<
cout<<
" *** Total =" << total<< endl;
"*** Total="<<total<<endl;
cout<<
cout<<
" *** Average =" << average<< endl;
"*** Average="<<average<<endl;
cout<<
cout<<
" +++++++++++++++++++++++++++++家庭:索拉; font-size:x-small"> << endl;
"++++++++++++++++++"<<endl;
total =(test1 + test2 + test3);
total = (test1+ test2+test3);
cin>>总计;
cin>>total;
average = total /(3);
average= total/(3);
cin>> average;
cin>> average;
返回
0;
return 0;
}
运行时检查失败#3 - 正在使用变量'total'而未初始化。
运行时检查失败#3 - 正在使用变量'average'而未初始化
i了解程序是不计算总数和平均数,我需要解决什么问题。非常感谢任何人可以帮助我
推荐答案
total =(test1 + test2 + test3);
total = (test1+ test2+test3);
cin> > total; //更改为cout<< total;
cin>>total; // change to cout << total;
average = total /(3);
average= total/(3);
cin>> average ; //更改为cout<< average;
cin>> average; // change to cout << average;
这篇关于运行时初始化失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!