⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 文件包含了很多VC实例
💻 CPP
字号:
#include <iostream>
using namespace std;
struct student_info
{
  string strName;
  int chinese;
  int math;
  int english;
};
student_info student[50];
int main()
{
	int i = 0 ;                                  //循环变量
	char a[20];
	for( i = 0 ; i < 50 ; i++ )
	{
		cout<<"Enter the "<<i+1<<"student's information :"<<endl;
		cout<<"Enter name :"<<endl;
		cin>>a;
		student[i].strName = a;
		cout<<"Enter Chinese preformance:"<<endl;
		cin>>student[i].chinese;
		cout<<"Enter Math preformance:"<<endl;
		cin>>student[i].math;
		cout<<"Enter English preformance:"<<endl;
		cin>>student[i].english;
	}
	for( i = 0 ; i < 50 ; i++ )
	{
		cout<<"The "<<i+1<<"student's information :"<<endl;
		cout<<"Name :"<<student[i].strName.c_str()<<endl;
		cout<<"Chinese preformance:"<<student[i].chinese<<endl;
		cout<<"Math preformance:"<<student[i].math<<endl;
		cout<<"English preformance:"<<student[i].english<<endl;
	}
	int avgChinese = 0 ;
	int avgMath = 0 ;
	int avgEnglish = 0 ;
	int total = 0 ;
	i = 0 ;
	while(i<50)
	{
		total += student[i].chinese;
		i++;
	}
	avgChinese = total / 50 ;
	total = 0 ;
	i = 0 ;
	while(i<50)
	{
		total += student[i].math;
		i++;
	}
	avgMath = total / 50 ;
	total = 0 ;
	i = 0 ;
	while(i<50)
	{
		total += student[i].english;
		i++;
	}
	avgEnglish = total / 50 ;
	cout<<"Enter 1 for look up the average of Chinese.\n"
		<<"Enter 2 for look up the average of Math.\n"
		<<"Enter 3 for look up the average of English.\n";
	cin>>i;
	switch(i)
	{
	case 1:
		cout<<"Average of Chinese is : "<<avgChinese<<endl;
		break;
	case 2:
        cout<<"Average of Math is : "<<avgMath<<endl;
		break;
	case 3:
        cout<<"Average of English is : "<<avgEnglish<<endl;
		break;
	default:
		cout<<"Please enter 1,2or3"<<endl;
		break;
	}
	cin.get();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -