网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
c++,运行下面代码出错

#include <iostream>using namespace std;struct student_info{ string name; int chinese; int math; int english;};student_info student[5];void inputinfo(){ int i = 0; char a[20]; for(i = 0;i < 5;i++) { cout<<"enter the "<<i+1<<" student's information "<<endl; cout<<"enter the name"<<endl; cin>>a; student[i].name = a; cout<<"enter chinese performance :"<<endl; cin>>student[i].chinese; cout<<"enter math performance :"<<endl; cin>>student[i].math; cout<<"enter english performance :"<<endl; cin>>student[i].english; }}void outputinfo(){ int i = 0; while(i < 5) { cout<<i+1<<" student's information"<<endl; cout<<student[i].name.c_str()<<endl; cout<<"chinese "<<endl; cout<<student[i].chinese<<endl; cout<<"math "<<endl; cout<<student[i].math<<endl; cout<<"english "<<endl; cout<<student[i].english<<endl; i++; }}int avgfunction(int arr[],int n){ int i = 0; int total = 0; for(i = 0;i < n;i++) { total += arr[i]; } return total / n;}void computavg() //这里是否正确?{ int theavg = 0; theavg = avgfunction(student[i].chinese,5); }int main(){ inputinfo(); outputinfo(); computavg(); cin.get(); return 0;} 帮我找出错误 然后改过来 择优为满意答案 不分先后


参考答案

更多 “ c++,运行下面代码出错 #include iostreamusing namespace std;struct student_info{ string name; int chinese; int math; int english;};student_info student[5];void inputinfo(){ int i = 0; char a[20]; for(i = 0;i 5;i++) { cout"enter the "i+1" student's information "endl; cout"enter the name"endl; cina; student[i].name = a; cout"enter chinese performance :"endl; cinstudent[i].chinese; cout"enter math performance :"endl; cinstudent[i].math; cout"enter english performance :"endl; cinstudent[i].english; }}void outputinfo(){ int i = 0; while(i 5) { couti+1" student's information"endl; coutstudent[i].name.c_str()endl; cout"chinese "endl; coutstudent[i].chineseendl; cout"math "endl; coutstudent[i].mathendl; cout"english "endl; coutstudent[i].englishendl; i++; }}int avgfunction(int arr[],int n){ int i = 0; int total = 0; for(i = 0;i n;i++) { total += arr[i]; } return total / n;}void computavg() //这里是否正确?{ int theavg = 0; theavg = avgfunction(student[i].chinese,5); }int main(){ inputinfo(); outputinfo(); computavg(); cin.get(); return 0;} 帮我找出错误 然后改过来 择优为满意答案 不分先后 ” 相关考题
考题 下列代码经过编译将输出()。A.99B.0C.编译出错D.运行出错

考题 下面说法不是断点特点是()。 A、它是调试器的功能之一B、程序运行到这一行就会停住,然后你可以一步一步往下调试C、调试过程中可以看各个变量当前的值,出错的话,调试到出错的代码行即显示错误停下D、调试过程中不可以看各个变量当前的值,出错的话,调试到出错的代码行即显示错误停下

考题 阅读下面代码 public class Test { String s="One World One Dream"; public static void main(String[] args) { System.out.println(s); } } 其运行的结果是A.argsB.World One DreamC.sD.编译时出错

考题 阅读下列代码其运行结果是( )。A.JavaB.LanguageC.TestD.编译时出错

考题 下面代码段的输出是( )。A.编译出错B.5752C.trueD.无任何输出

考题 阅读下列说明、c++代码和运行结果,填补代码中的空缺(1)~(6),将解答填入答题纸的对应栏内。【说明】很多依托扑克牌进行的游戏都要先洗牌。下面的c++程序运行时先生成一副扑克牌,洗牌后再按顺序打印每张牌的点数和花色。【c++代码】inciude <iostream>4Finclude <stdlib. h>include <ctime>inciude <aigorithm>include <string>Using namespace stdConst string Rank[13]={”A”,”2”,”3”,”4“,“5”,”6,”’“7”8“,9”,”10,”J”,”Q”,”K”}j//扑克牌点数

考题 12、下面代码的运行结果是‪‪‪‪‪‫‪‪‪‪‪‪‫‪‪‪‪‪‪‪‪‪‪‪‫‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪‪ def func(num): num+=1 a=10 func(a) print(a)A.10B.intC.11D.出错

考题 5、下面代码的输出结果是()。 def printpara(x): '''just print x''' print(x) printpara("Hi")A.just print xB.xC.HiD.出错

考题 找出错误并修改下面的代码: public class Test{ public static void main(String[] args){ double[100] r; for(int i = 0; i < r.length(); i++); r(i) = Math.random * 100; } }指出错误代码的位置,并写出修改后的正确代码。提交的作业内容中的程序代码以代码格式提交(如题目中的代码)。

考题 11、下面代码的运行结果是 def func(num) : num += 1 a = 10 func(a) print(a)A.10B.11C.出错D.int