amnotsure 2022-04-27 21:22 采纳率: 80%
浏览 19
已结题

c++程序运行错误求解!

想问一下这个c++程序哪里出了错误,然后应该怎么改过来,求解!

img

img

img

  • 写回答

1条回答 默认 最新

  • 小白小白你好菜 2022-04-27 22:11
    关注
    #include<iostream>
    using namespace std;
    
    class Student{
    	public:
    		void scoretotalcount(double s);
    		static float sum();
    		static float average();
    	private:
    		float score;
    		static float total;
    		static int count;
    };
    
    void Student::scoretotalcount(double s){
    	score = s;
    	total += s;
    	count++;
    }
    
    float Student::sum(){
    	return total;
    }
    
    float Student::average(){
    	float av;
    	av = total / count;
    	return av;
    }
    
    float Student::total = 0;
    int Student::count = 0;
    
    int main(){
    	Student a;
    	double score;
    	cout << "请输入班级成绩:(-1结束)" << endl;
    	cin >> score;
    	while(score != -1){
    		a.scoretotalcount(score);
    		cin >> score;
    	}
    	cout << "全班总分为:" << a.sum() << endl;
    	cout << "全班平均分为:" << a.average() << endl;
    	return 0;
    }
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月6日
  • 已采纳回答 3月29日
  • 创建了问题 4月27日

悬赏问题

  • ¥20 虚幻UE引擎如何让多个同一个蓝图的NPC执行一样的动画,
  • ¥15 fluent里模拟降膜反应的UDF编写
  • ¥15 MYSQL 多表拼接link
  • ¥15 关于某款2.13寸墨水屏的问题
  • ¥15 obsidian的中文层级自动编号
  • ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵
  • ¥15 券商软件上市公司信息获取问题