这是警告而已,不是错误,是正常情况,程序已经成功编译并运行了,没有问题的

你看报错信息只有3个,都是同类型错误,意思是scanf不安全,用scanf_s代替,你试试看

你的是什么版本呢,我这边没有这样的问题

您好,以下为更新后的代码及运行结果,如果没有问题的话,麻烦您确认一下,给个五星好评哈!谢谢!

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
class Student{
public:
string stuId;
string name;
double mathScore;
double chineseScore;
double englishScore;
};

typedef pair<string, float> PAIR;
bool cmp_by_value(const PAIR& lhs, const PAIR& rhs) {
return lhs.second > rhs.second;
}

int main() {
// task1
const int n = 4;
Student students[n];
// task2
for(int i=0; i<n; i++){
cout<<“Enter StudentId of student” << (i+1) << endl;
cin>>students[i].stuId;
cout<<“Enter name of student” << (i+1) << endl;
cin>>students[i].name;
cout<<“Enter mathScore of student” << (i+1) << endl;
scanf(“%lf”, &students[i].mathScore);
cout<<“Enter chineseScore of student” << (i+1) << endl;
scanf(“%lf”, &students[i].chineseScore);
cout<<“Enter englishScore of student” << (i+1) << endl;
scanf(“%lf”, &students[i].englishScore);
}
cout<<“All students’ information:”<< endl;
for (int i = 0; i < n; i++){
cout<<“Student” << (i+1) << “- stuId: ” << students[i].stuId << “, name: ” << students[i].name << “, mathScore: “
<< students[i].mathScore << “, chineseScore: ” << students[i].chineseScore<< “, englishScore: ” << students[i].englishScore<< endl;
}

// task3
map<string, int> id_score_map;
for (int i = 0; i < n; i++) {
id_score_map[students[i].stuId] = 1.0*(students[i].mathScore+students[i].chineseScore+students[i].englishScore)/3.0;
}
vector<PAIR> id_score_vec(id_score_map.begin(), id_score_map.end());
sort(id_score_vec.begin(), id_score_vec.end(), cmp_by_value);
for (int i = 0; i != id_score_vec.size(); ++i) {
cout<<id_score_vec[i].first<<” “<<id_score_vec[i].second<<endl;
}

// task4
cout<<“Student ID whose average mark is smaller than the average mark”<<endl;
float scores = 0.0;
for (int i = 0; i != id_score_vec.size(); ++i) {
scores += id_score_vec[i].second;
}
float average_score = 1.0*scores/n;
for (int i = 0; i != id_score_vec.size(); ++i) {
if (id_score_vec[i].second < average_score){
cout<<id_score_vec[i].first<<” “;
}
}
return 0;
}

 

\"\"

Reminder
OK
作业代写,代写作业,作业辅导,辅导作业,作业问答,美国作业代写,留学生作业,留学生作业代写,数学作业,数学作业代写,统计作业代写,物理作业代写,金融作业代写,大学作业辅导 Keywords: 作业代写 代写作业 作业辅导 辅导作业 作业问答 美国作业代写 留学生作业 留学生作业代写 数学作业 数学作业代写 统计作业代写 物理作业代写 金融作业代写 大学作业辅导