cpp: pointer

 VS 2022 C++有两种注释方法,一种C++的,还有一种和C#差不多。

读写文件有生成有报错,文件头行加上这行代码

#define _CRT_SECURE_NO_WARNINGS

自定义数据结构数组指针,类对象指针,不熟,瞎摸象,我不知道赋值,调用......

/*****************************************************************//**
 * \file   geovindu.h
 * \brief  业务操作方法
 *
 * \author geovindu,Geovin Du
 * \date   2023-04-05
***********************************************************************/
/*
* 注释插件
https://www.doxygen.nl/download.html
https://computingonplains.wordpress.com/doxygen-and-visual-studio/
https://marketplace.visualstudio.com/items?itemName=sergeb.GhostDoc
https://marketplace.visualstudio.com/items?itemName=FinnGegenmantel.doxygenComments
https://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/comments/



*/

#ifndef GEOVINDU_H
#define GEOVINDU_H
#include <vector> // #include directive
#include <string>
#include <iostream>
#include <string.h>
#include <list>
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include <vector> 
#include <memory> 





//#include <sqlite3.h>
#include "PigInfo.h"
#include "PigNameInfo.h"
#include "CinemaScore.h"
#include "OpenDoor.h"
#include "LeapYear.h"
#include "RandomlySampled.h"
#include "NumberLottery.h"  
#include "InputNumberMax.h"
#include "DeskKnock.h"
#include "NarcissisticNumber.h"
#include "NarcissisticInfo.h"
#include "NarcissisticList.h"
#include "MultiplicationTables.h"
#include "CardinalDirection.h"
#include "CSVfilemanagement.h"
#include "ATMdemo.h"
#include "csvstream.h"
//#include "csvparser.h"
#include "StudentArry.h"
#include "student.h"
#include "StudentMenu.h"
#include "StudentList.h"

//#include "GeovinStudent.h"



using namespace std;



/**
* @brief 类库空间名
* geovindu edit
*
*/
namespace geovindu
{






	/**
	* @brief 简要说明文字
	*/
	enum class colors : short { red, blue, purple, azure };
	/**
	* @brief 简要说明文字
	*/
	struct RGB
	{
		short r{ 0 };  // member initialization
		short g{ 0 };
		short b{ 0 };
	};


	/// <summary>
   /// 信息
   /// </summary>
	struct GeovinStudent
	{

		/// <summary>
		/// 姓名
		/// </summary>
		std::string studentName;
		/// <summary>
		/// 语文
		/// </summary>
		int chineseScore;
		/// <summary>
		/// 英语
		/// </summary>
		int englishScore;
		/// <summary>
		/// 数学
		/// </summary>
		int mathScore;
		/// <summary>
		/// 
		/// </summary>
		int computerScore;
		/// <summary>
		/// 个人总分
		/// </summary>
		int studentTotalScore = chineseScore + englishScore + mathScore + computerScore; //计算 无效
		/// <summary>
		/// 平均
		/// </summary>
		int subjectAverage;
		/// <summary>
		/// 名次
		/// </summary>
		int rankingScore;



	};


	/// <summary>
	/// 语文成绩排序,降  从大到小
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpChineseAsc(const GeovinStudent* a, const GeovinStudent* b)
	{
		return a->chineseScore > b->chineseScore;
	}
	/// <summary>
	/// 语文成绩排序,升 从小到大
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpChineseDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->chineseScore < b->chineseScore;
	}

	/// <summary>
	/// 英语成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpEnglishDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->englishScore > b->englishScore;
	}
	/// <summary>
	/// 英语成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpEnglishAsc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->englishScore < b->englishScore;
	}

	/// <summary>
	/// 数学成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpMathDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->mathScore > b->mathScore;
	}
	/// <summary>
	/// 数学成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpMathAsc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->mathScore < b->mathScore;
	}


	/// <summary>
	/// 计算机成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpComputerDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->computerScore > b->computerScore;
	}
	/// <summary>
	/// 计算机成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpComputerAsc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->computerScore < b->computerScore;
	}

	/// <summary>
	/// 个人总分成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpTotalScoreDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->studentTotalScore > b->studentTotalScore;
	}
	/// <summary>
	/// 个人总分成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpTotalScoreAsc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->studentTotalScore < b->studentTotalScore;
	}


	// Function for comparing two students according
	// to given rules
	
	/// <summary>
	/// 
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool compareTwoStudentsPoointer(const GeovinStudent* a, const GeovinStudent* b)
	{
		// If total marks are not same then
		// returns true for higher total
		if (a->studentTotalScore != b->studentTotalScore)
			return a->studentTotalScore > b->studentTotalScore;

		// If marks in Maths are same then
		// returns true for higher marks
		if (a->chineseScore != b->chineseScore)
			return a->chineseScore > b->chineseScore;

		if (a->computerScore != b->computerScore)
			return a->computerScore > b->computerScore;

		if (a->englishScore != b->englishScore)
			return a->englishScore > b->englishScore;

		return (a->mathScore > b->mathScore);
	}

	// Fills total marks and ranks of all Students

	/// <summary>
	/// 
	/// </summary>
	/// <param name="a"></param>
	/// <param name="n"></param>
	void computeRanksPoointer(GeovinStudent* a[], int n)
	{
		// To calculate total marks for all Students
		for (int i = 0; i < n; i++)
			//a[i]->studentTotalScore = a[i]->chineseScore + a[i]->computerScore + a[i]->englishScore+a[i]->mathScore;

		// Sort structure array using user defined
		// function compareTwoStudents()
		 sort(a, a + n, compareTwoStudentsPoointer);
		//sort(bgein(a), end(a), compareTwoStudents);

		// Assigning ranks after sorting
		for (int i = 0; i < n; i++)
		{
			//a[i]->rankingScore = i + 1;
		}
	}

		// Function for comparing two students according
	// to given rules
	bool compareTwoStudents(GeovinStudent a, GeovinStudent b)
	{
		// If total marks are not same then
		// returns true for higher total
		if (a.studentTotalScore != b.studentTotalScore)
			return a.studentTotalScore > b.studentTotalScore;

		// If marks in Maths are same then
		// returns true for higher marks
		if (a.chineseScore != b.chineseScore)
			return a.chineseScore > b.chineseScore;

		if (a.computerScore != b.computerScore)
			return a.computerScore > b.computerScore;

		if (a.englishScore != b.englishScore)
			return a.englishScore > b.englishScore;

		return (a.mathScore > b.mathScore);
	}

	// Fills total marks and ranks of all Students
	void computeRanks(GeovinStudent a[], int n)
	{
		// To calculate total marks for all Students
		for (int i = 0; i < n; i++)
			a[i].studentTotalScore = a[i].chineseScore + a[i].computerScore + a[i].englishScore + a[i].mathScore;

		// Sort structure array using user defined
		// function compareTwoStudents()
		sort(a, a + n, compareTwoStudents);
		//sort(bgein(a), end(a), compareTwoStudents);

		// Assigning ranks after sorting
		for (int i = 0; i < n; i++)
		{
			a[i].rankingScore = i + 1;
		}
	}


	/**
	*@brief if 比较小猪等作业 实现方法业务
	* edit: geovindu
	*/
	class Geovin
	{

	



	private:



	public:
		/**
		*@brief
		*三只小猪重量比较方法(函数)
		* eidt: geovindu
		*/
		void getPig();
		/**
		*@brief
		*数据类型占内存空间
		* edig: geovindu
		*/
		void dataTypeSize();
		/**
		*@brief
		*实体类三只小猪重量比较方法(函数)
		*edit: geovindu
		*/
		void getPigClass();

		/**
		*@brief
		*画星行列显示 方法(函数)
		*eidit: geovindu
		*/
		void displayFiveStars();

		/**
		*@brief
		*@param [int] 输入参数名称  行数
		*@param [int] 输入参数名称  列数
		*运画星行列显示方法(函数)
		* ediit: geovindu
		*/
		void displayFiveStars(int row, int column);
		/**
		*@brief
		*@param [char] 输入参数名称  ASCii字符数组
		*ASCii显示方法(函数)
		* ediit: geovindu
		*/
		void displayASCII(char ascii[]);
		/**
		*@brief
		*@param [long] 输入参数名称  运算的第一个数
		*@param [long] 输入参数名称  运算的第二个数
		*运算符示例 方法(函数)
		* ediit: geovindu
		*/
		void dipslayOperate(long a, long b);
		/**
		*@brief
		*@param [int] 输入参数  第一个整数
		*@param [int] 输入参数  第二个整数
		*三目运算符示例的显示方法(函数)
		* ediit: geovindu
		*/
		void TrinocularOperator(int a, int b);
		/**
		*@brief
		*@param [long] 输入参数  成绩分数
		*判断成绩的及格否(函数)
		* ediit: geovindu
		*/
		void IsPassExamination(long exam);
		/**
		* @brief
		*/
		void DisplayCinema();
		/**
		* @brief
		*/
		void DisplayDoor();
		/**
		* @brief
		*/
		void DisplayDays();
		/**
		* @brief
		*/
		void DisplayWhile();
		/**
		* @brief
		*/
		void DisplayRomd();
		/**
		* @brief
		*/
		void DisplayRomd(int number);
		/**
		* @brief
		*/
		void DisplayRomd(int number, std::list<std::string> choices);

		/**
		 * @brief.
		 *
		 */
		void DisplayNumberLottery();

		/**
		 * @brief.
		 *
		 * \param maxnum 【int】输入参数: 整数
		 */
		void DisplayMaxSum(int maxnum);
		/**
		 * @brief .敲桌子
		 *
		 * \param maxnum 【int】输入参数: 整数
		 */
		void DisplayDeskKnock(int maxnum);
		/**
		 * @brief 水仙花数.
		 * 100至1000内的三位数的水仙花数
		 */
		void DisplayNarcissisticNumber();
		/**
		 * @brief 水仙花数.
		 * 指定范围内的整数中的水仙花数
		 * \param min 输入参数 【int】 范围内的最小整数
		 * \param max 输入参数 【int】 范围内的最大整数
		 */
		void DisplayNarcissisticNumber(int min, int max);

		/**
		 * @brief 水仙花数. 实体类
		 * 100至1000内的三位数的水仙花数
		 */
		list<NarcissisticInfo> DisplayNarcissicticInfos();

		//NarcissisticInfo getInfo();
		/**
		 * @brief .
		 *
		 * \return
		 */
		NarcissisticList getInfo();
		/**
		 * @brief.
		 *
		 */
		void DisplayMultiplicationTables();
		/**
		 * @brief 写.
		 *
		 */
		void CsvCreate();
		/// <summary>
		/// 
		/// </summary>
		void DisplayAtemDemo();
		/// <summary>
		/// 
		/// </summary>
		void Displaycsv();

		/**
		 * @brief 显示学生成绩
		 *
		 * */
		void displayScore();
		/// <summary>
		/// 
		/// </summary>
		void StudentWelcome();
		/// <summary>
		/// 
		/// </summary>
		void StudentMenuDisplay();
		/// <summary>
		/// 
		/// </summary>
		void DisplayStudent();
		/// <summary>
		/// 
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		//bool compareTwoStudents(const GeovinStudent* a,const GeovinStudent* b);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="a"></param>
		/// <param name="n"></param>
		//void computeRanks(const GeovinStudent (*a)[], int n);
		/// <summary>
		/// 
		/// </summary>
		void DisplayVectorStudent();


	};
	
	/// <summary>
	/// 
	/// </summary>
	void Geovin::DisplayVectorStudent()
	{
		//GeovinStudent* slist = new GeovinStudent[3];
		GeovinStudent slist[3];
		//slist ={
			//{"geovin",25,45,95,75},{"张三",55,65,45,55},{"涂聚文",25,85,95,75}
		  // };;
		slist[0] = {"geovin",25,45,95,75 };
		slist[1] = {"张三",55,65,45,55};
		slist[2] = { "涂聚文",25,85,95,75 };


		//GeovinStudent* slistPointer = new GeovinStudent[3];
		//GeovinStudent* stuDu = new GeovinStudent;
		//stuDu->studentName = "geovin";
		//stuDu->chineseScore = 25;
		//stuDu->computerScore = 45;
		//stuDu->englishScore = 95;
		//stuDu->mathScore = 75;
		////slistPointer= &slist;
		//stuDu = &slistPointer[0];

		GeovinStudent* slistPointer[3];


		//slistPointer[0]->studentName = "";// {"geovin", 25, 45, 95, 75 };

		//slist = { };
		GeovinStudent* student = new GeovinStudent;
		student->studentName = "geovin";
		student->chineseScore = 25;
		student->computerScore = 45;
		student->englishScore = 95;
		student->mathScore = 75;	
	
	    
		vector<GeovinStudent *> stu;
		stu.push_back(student);

		slistPointer[0]= student;

		GeovinStudent* student2 = new GeovinStudent;
		student2->studentName = "张三";
		student2->chineseScore = 55;
		student2->computerScore = 89;
		student2->englishScore = 94;
		student2->mathScore = 62;
		stu.push_back(student2);
		slistPointer[1]= student2;


		GeovinStudent* student3 = new GeovinStudent;
		student3->studentName = "涂聚文";
		student3->chineseScore = 35;
		student3->computerScore = 85;
		student3->englishScore = 45;
		student3->mathScore = 95;
		stu.push_back(student3);
		slistPointer[2]== student3;

		//GeovinStudent* stu1 = new GeovinStudent;

		//

		// sort(begin(stu),end(stu), cmpChineseAsc);
		 
		//vector<GeovinStudent> slist;
		//vector<GeovinStudent*> slist;
	 //	GeovinStudent student;
		//student.studentName = "geovin";
		//student.chineseScore = 25;
		//student.computerScore = 45;
		//student.englishScore = 95;
		//student.mathScore = 75;
		//slist.push_back(student);
		//student.studentName = "张三";
		//student.chineseScore = 55;
		//student.computerScore = 65;
		//student.englishScore = 45;
		//student.mathScore = 55;
		//slist.push_back(student);
		//student.studentName = "涂聚文";
		//student.chineseScore = 25;
		//student.computerScore = 85;
		//student.englishScore = 85;
		//student.mathScore = 75;
		//slist.push_back(student);

		//cout << "姓名" << "语文" << "英语" << "数学"<<"总分" << endl;
		//for (auto du : slist)
		//{
		//	cout << du.studentName << du.chineseScore << du.computerScore << du.englishScore << du.mathScore << du.studentTotalScore << endl;


		//}

		cout << "姓名\t" << "语文\t" << "计算机\t" << "英语\t" << "数学\t"<<"总分\t" << endl;
		 for (auto du : stu)
		{
			 du->studentTotalScore = du->chineseScore + du->englishScore + du->mathScore + du->computerScore;
 			cout << du->studentName<<"\t" << du->chineseScore << "\t" << du->computerScore << "\t" << du->englishScore << "\t" << du->mathScore << "\t" << du->studentTotalScore << endl;

		}
		 sort(begin(stu), end(stu), cmpMathDesc); //数学排序
		 //sort(slist,slist.size(), cmpMathAsc)
		 //sort(stu, stu.size(), cmpMathAsc)
		 cout << "*********数学排序****************" << endl;
		 for (auto du : stu)
		 {
			 du->studentTotalScore = du->chineseScore + du->englishScore + du->mathScore + du->computerScore;
			 cout << du->studentName << "\t" << du->chineseScore << "\t" << du->computerScore << "\t" << du->englishScore << "\t" << du->mathScore << "\t" << du->studentTotalScore << endl;

		 }
		 cout << "**********总分排序***************" << endl;
		 computeRanks(slist, 3);
		 for (auto du : slist)
		 {
			 cout << du.studentName << "\t" << du.chineseScore << "\t" << du.computerScore << "\t" << du.englishScore << "\t" << du.mathScore << "\t" << du.studentTotalScore << endl;
		 }

		 cout << "**********总分排序***************" << endl;

		 computeRanksPoointer(slistPointer, 3);
		 for (auto du : slistPointer)
		 {
			 cout << du->studentName << "\t" << du->chineseScore << "\t" << du->computerScore << "\t" << du->englishScore << "\t" << du->mathScore << "\t" << du->studentTotalScore << endl;
		 }


	}

  

 

 

/*****************************************************************//**
 * \file   geovindu.h
 * \brief  业务操作方法
 *
 * \author geovindu,Geovin Du
 * \date   2023-04-05
***********************************************************************/
/*
* 注释插件
https://www.doxygen.nl/download.html
https://computingonplains.wordpress.com/doxygen-and-visual-studio/
https://marketplace.visualstudio.com/items?itemName=sergeb.GhostDoc
https://marketplace.visualstudio.com/items?itemName=FinnGegenmantel.doxygenComments
https://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/comments/



*/

#ifndef GEOVINDU_H
#define GEOVINDU_H
#include <vector> // #include directive
#include <string>
#include <iostream>
#include <string.h>
#include <list>
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include <vector> 
#include <memory> 





//#include <sqlite3.h>
#include "PigInfo.h"
#include "PigNameInfo.h"
#include "CinemaScore.h"
#include "OpenDoor.h"
#include "LeapYear.h"
#include "RandomlySampled.h"
#include "NumberLottery.h"  
#include "InputNumberMax.h"
#include "DeskKnock.h"
#include "NarcissisticNumber.h"
#include "NarcissisticInfo.h"
#include "NarcissisticList.h"
#include "MultiplicationTables.h"
#include "CardinalDirection.h"
#include "CSVfilemanagement.h"
#include "ATMdemo.h"
#include "csvstream.h"
//#include "csvparser.h"
#include "StudentArry.h"
#include "student.h"
#include "StudentMenu.h"
#include "StudentList.h"

//#include "GeovinStudent.h"



using namespace std;



/**
* @brief 类库空间名
* geovindu edit
*
*/
namespace geovindu
{






	/**
	* @brief 简要说明文字
	*/
	enum class colors : short { red, blue, purple, azure };
	/**
	* @brief 简要说明文字
	*/
	struct RGB
	{
		short r{ 0 };  // member initialization
		short g{ 0 };
		short b{ 0 };
	};


	/// <summary>
   /// 信息
   /// </summary>
	struct GeovinStudent
	{

		/// <summary>
		/// 姓名
		/// </summary>
		std::string studentName;
		/// <summary>
		/// 语文
		/// </summary>
		int chineseScore;
		/// <summary>
		/// 英语
		/// </summary>
		int englishScore;
		/// <summary>
		/// 数学
		/// </summary>
		int mathScore;
		/// <summary>
		/// 
		/// </summary>
		int computerScore;
		/// <summary>
		/// 个人总分
		/// </summary>
		int studentTotalScore = chineseScore + englishScore + mathScore + computerScore; //计算 无效
		/// <summary>
		/// 平均
		/// </summary>
		int subjectAverage;
		/// <summary>
		/// 名次
		/// </summary>
		int rankingScore;



	};


	/// <summary>
	/// 语文成绩排序,降  从大到小
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpChineseAsc(const GeovinStudent* a, const GeovinStudent* b)
	{
		return a->chineseScore > b->chineseScore;
	}
	/// <summary>
	/// 语文成绩排序,升 从小到大
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpChineseDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->chineseScore < b->chineseScore;
	}

	/// <summary>
	/// 英语成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpEnglishDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->englishScore > b->englishScore;
	}
	/// <summary>
	/// 英语成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpEnglishAsc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->englishScore < b->englishScore;
	}

	/// <summary>
	/// 数学成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpMathDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->mathScore > b->mathScore;
	}
	/// <summary>
	/// 数学成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpMathAsc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->mathScore < b->mathScore;
	}


	/// <summary>
	/// 计算机成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpComputerDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->computerScore > b->computerScore;
	}
	/// <summary>
	/// 计算机成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpComputerAsc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->computerScore < b->computerScore;
	}

	/// <summary>
	/// 个人总分成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpTotalScoreDesc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->studentTotalScore > b->studentTotalScore;
	}
	/// <summary>
	/// 个人总分成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpTotalScoreAsc(GeovinStudent* a, GeovinStudent* b)
	{
		return a->studentTotalScore < b->studentTotalScore;
	}


	//// Function for comparing two students according
	//// to given rules
	//bool compareTwoStudents(GeovinStudent* a, GeovinStudent* b)
	//{
	//	// If total marks are not same then
	//	// returns true for higher total
	//	if (a->studentTotalScore != b->studentTotalScore)
	//		return a->studentTotalScore > b->studentTotalScore;

	//	// If marks in Maths are same then
	//	// returns true for higher marks
	//	if (a->chineseScore != b->chineseScore)
	//		return a->chineseScore > b->chineseScore;

	//	if (a->computerScore != b->computerScore)
	//		return a->computerScore > b->computerScore;

	//	if (a->englishScore != b->englishScore)
	//		return a->englishScore > b->englishScore;

	//	return (a->mathScore > b->mathScore);
	//}

	//// Fills total marks and ranks of all Students
	//void computeRanks(GeovinStudent* a[], int n)
	//{
	//	// To calculate total marks for all Students
	//	for (int i = 0; i < n; i++)
	//		a[i]->studentTotalScore = a[i]->chineseScore + a[i]->computerScore + a[i]->englishScore+a[i]->mathScore;

	//	// Sort structure array using user defined
	//	// function compareTwoStudents()
	//	 sort(a, a + n, compareTwoStudents);
	//	//sort(bgein(a), end(a), compareTwoStudents);

	//	// Assigning ranks after sorting
	//	for (int i = 0; i < n; i++)
	//	{
	//		a[i]->rankingScore = i + 1;
	//	}
	//}

		// Function for comparing two students according
	// to given rules
	bool compareTwoStudents(GeovinStudent a, GeovinStudent b)
	{
		// If total marks are not same then
		// returns true for higher total
		if (a.studentTotalScore != b.studentTotalScore)
			return a.studentTotalScore > b.studentTotalScore;

		// If marks in Maths are same then
		// returns true for higher marks
		if (a.chineseScore != b.chineseScore)
			return a.chineseScore > b.chineseScore;

		if (a.computerScore != b.computerScore)
			return a.computerScore > b.computerScore;

		if (a.englishScore != b.englishScore)
			return a.englishScore > b.englishScore;

		return (a.mathScore > b.mathScore);
	}

	// Fills total marks and ranks of all Students
	void computeRanks(GeovinStudent a[], int n)
	{
		// To calculate total marks for all Students
		for (int i = 0; i < n; i++)
			a[i].studentTotalScore = a[i].chineseScore + a[i].computerScore + a[i].englishScore + a[i].mathScore;

		// Sort structure array using user defined
		// function compareTwoStudents()
		sort(a, a + n, compareTwoStudents);
		//sort(bgein(a), end(a), compareTwoStudents);

		// Assigning ranks after sorting
		for (int i = 0; i < n; i++)
		{
			a[i].rankingScore = i + 1;
		}
	}


	/**
	*@brief if 比较小猪等作业 实现方法业务
	* edit: geovindu
	*/
	class Geovin
	{

	



	private:



	public:
		/**
		*@brief
		*三只小猪重量比较方法(函数)
		* eidt: geovindu
		*/
		void getPig();
		/**
		*@brief
		*数据类型占内存空间
		* edig: geovindu
		*/
		void dataTypeSize();
		/**
		*@brief
		*实体类三只小猪重量比较方法(函数)
		*edit: geovindu
		*/
		void getPigClass();

		/**
		*@brief
		*画星行列显示 方法(函数)
		*eidit: geovindu
		*/
		void displayFiveStars();

		/**
		*@brief
		*@param [int] 输入参数名称  行数
		*@param [int] 输入参数名称  列数
		*运画星行列显示方法(函数)
		* ediit: geovindu
		*/
		void displayFiveStars(int row, int column);
		/**
		*@brief
		*@param [char] 输入参数名称  ASCii字符数组
		*ASCii显示方法(函数)
		* ediit: geovindu
		*/
		void displayASCII(char ascii[]);
		/**
		*@brief
		*@param [long] 输入参数名称  运算的第一个数
		*@param [long] 输入参数名称  运算的第二个数
		*运算符示例 方法(函数)
		* ediit: geovindu
		*/
		void dipslayOperate(long a, long b);
		/**
		*@brief
		*@param [int] 输入参数  第一个整数
		*@param [int] 输入参数  第二个整数
		*三目运算符示例的显示方法(函数)
		* ediit: geovindu
		*/
		void TrinocularOperator(int a, int b);
		/**
		*@brief
		*@param [long] 输入参数  成绩分数
		*判断成绩的及格否(函数)
		* ediit: geovindu
		*/
		void IsPassExamination(long exam);
		/**
		* @brief
		*/
		void DisplayCinema();
		/**
		* @brief
		*/
		void DisplayDoor();
		/**
		* @brief
		*/
		void DisplayDays();
		/**
		* @brief
		*/
		void DisplayWhile();
		/**
		* @brief
		*/
		void DisplayRomd();
		/**
		* @brief
		*/
		void DisplayRomd(int number);
		/**
		* @brief
		*/
		void DisplayRomd(int number, std::list<std::string> choices);

		/**
		 * @brief.
		 *
		 */
		void DisplayNumberLottery();

		/**
		 * @brief.
		 *
		 * \param maxnum 【int】输入参数: 整数
		 */
		void DisplayMaxSum(int maxnum);
		/**
		 * @brief .敲桌子
		 *
		 * \param maxnum 【int】输入参数: 整数
		 */
		void DisplayDeskKnock(int maxnum);
		/**
		 * @brief 水仙花数.
		 * 100至1000内的三位数的水仙花数
		 */
		void DisplayNarcissisticNumber();
		/**
		 * @brief 水仙花数.
		 * 指定范围内的整数中的水仙花数
		 * \param min 输入参数 【int】 范围内的最小整数
		 * \param max 输入参数 【int】 范围内的最大整数
		 */
		void DisplayNarcissisticNumber(int min, int max);

		/**
		 * @brief 水仙花数. 实体类
		 * 100至1000内的三位数的水仙花数
		 */
		list<NarcissisticInfo> DisplayNarcissicticInfos();

		//NarcissisticInfo getInfo();
		/**
		 * @brief .
		 *
		 * \return
		 */
		NarcissisticList getInfo();
		/**
		 * @brief.
		 *
		 */
		void DisplayMultiplicationTables();
		/**
		 * @brief 写.
		 *
		 */
		void CsvCreate();
		/// <summary>
		/// 
		/// </summary>
		void DisplayAtemDemo();
		/// <summary>
		/// 
		/// </summary>
		void Displaycsv();

		/**
		 * @brief 显示学生成绩
		 *
		 * */
		void displayScore();
		/// <summary>
		/// 
		/// </summary>
		void StudentWelcome();
		/// <summary>
		/// 
		/// </summary>
		void StudentMenuDisplay();
		/// <summary>
		/// 
		/// </summary>
		void DisplayStudent();
		/// <summary>
		/// 
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		//bool compareTwoStudents(const GeovinStudent* a,const GeovinStudent* b);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="a"></param>
		/// <param name="n"></param>
		//void computeRanks(const GeovinStudent (*a)[], int n);
		/// <summary>
		/// 
		/// </summary>
		void DisplayVectorStudent();


	};
	
	/// <summary>
	/// 
	/// </summary>
	void Geovin::DisplayVectorStudent()
	{
		//GeovinStudent* slist = new GeovinStudent[3];
		GeovinStudent slist[3];
		//slist ={
			//{"geovin",25,45,95,75},{"张三",55,65,45,55},{"涂聚文",25,85,95,75}
		  // };;
		slist[0] = {"geovin",25,45,95,75 };
		slist[1] = {"张三",55,65,45,55};
		slist[2] = { "涂聚文",25,85,95,75 };

		//slist = { };
		GeovinStudent* student = new GeovinStudent;
		student->studentName = "geovin";
		student->chineseScore = 25;
		student->computerScore = 45;
		student->englishScore = 95;
		student->mathScore = 75;	
	
	    
		vector<GeovinStudent *> stu;
		stu.push_back(student);
		

		GeovinStudent* student2 = new GeovinStudent;
		student2->studentName = "张三";
		student2->chineseScore = 55;
		student2->computerScore = 89;
		student2->englishScore = 94;
		student2->mathScore = 62;
		stu.push_back(student2);

		GeovinStudent* student3 = new GeovinStudent;
		student3->studentName = "涂聚文";
		student3->chineseScore = 35;
		student3->computerScore = 85;
		student3->englishScore = 45;
		student3->mathScore = 95;
		stu.push_back(student3);

		//GeovinStudent* stu1 = new GeovinStudent;

		//

		// sort(begin(stu),end(stu), cmpChineseAsc);
		 
		//vector<GeovinStudent> slist;
		//vector<GeovinStudent*> slist;
	 //	GeovinStudent student;
		//student.studentName = "geovin";
		//student.chineseScore = 25;
		//student.computerScore = 45;
		//student.englishScore = 95;
		//student.mathScore = 75;
		//slist.push_back(student);
		//student.studentName = "张三";
		//student.chineseScore = 55;
		//student.computerScore = 65;
		//student.englishScore = 45;
		//student.mathScore = 55;
		//slist.push_back(student);
		//student.studentName = "涂聚文";
		//student.chineseScore = 25;
		//student.computerScore = 85;
		//student.englishScore = 85;
		//student.mathScore = 75;
		//slist.push_back(student);

		//cout << "姓名" << "语文" << "英语" << "数学"<<"总分" << endl;
		//for (auto du : slist)
		//{
		//	cout << du.studentName << du.chineseScore << du.computerScore << du.englishScore << du.mathScore << du.studentTotalScore << endl;


		//}

		cout << "姓名\t" << "语文\t" << "计算机\t" << "英语\t" << "数学\t"<<"总分\t" << endl;
		 for (auto du : stu)
		{
			 du->studentTotalScore = du->chineseScore + du->englishScore + du->mathScore + du->computerScore;
 			cout << du->studentName<<"\t" << du->chineseScore << "\t" << du->computerScore << "\t" << du->englishScore << "\t" << du->mathScore << "\t" << du->studentTotalScore << endl;

		}
		 sort(begin(stu), end(stu), cmpMathDesc); //数学排序
		 //sort(slist,slist.size(), cmpMathAsc)
		 //sort(stu, stu.size(), cmpMathAsc)
		 cout << "*********数学排序****************" << endl;
		 for (auto du : stu)
		 {
			 du->studentTotalScore = du->chineseScore + du->englishScore + du->mathScore + du->computerScore;
			 cout << du->studentName << "\t" << du->chineseScore << "\t" << du->computerScore << "\t" << du->englishScore << "\t" << du->mathScore << "\t" << du->studentTotalScore << endl;

		 }
		 cout << "**********总分排序***************" << endl;
		 computeRanks(slist, 3);
		 for (auto du : slist)
		 {
			 cout << du.studentName << "\t" << du.chineseScore << "\t" << du.computerScore << "\t" << du.englishScore << "\t" << du.mathScore << "\t" << du.studentTotalScore << endl;
		 }



	}

  

 

以下这样写的,无法去引用,引用就报错:

// GeovinStudent.h : 此文件包含 "GeovinStudent" 类。学生数组成绩显示方法 C++ 14
// 2023年4月19日 涂聚文 Geovin Du edit.



#pragma once
#ifndef GEOVINSTUDENT_H 
#define GEOVINSTUDENT_H 


#include<iostream>
#include<string>
#include<string.h>
#include<sstream>
#include<algorithm>
#include<cstring>
#include<cmath>


using namespace std;


/**
*
*/
namespace geovindu
{

	/// <summary>
	/// 信息
	/// </summary>
	struct GeovinStudent
	{

		/// <summary>
		/// 姓名
		/// </summary>
		std::string studentName;
		/// <summary>
		/// 语文
		/// </summary>
		int chineseScore;
		/// <summary>
		/// 英语
		/// </summary>
		int englishScore;
		/// <summary>
		/// 数学
		/// </summary>
		int mathScore;
		/// <summary>
		/// 
		/// </summary>
		int computerScore;
		/// <summary>
		/// 个人总分
		/// </summary>
		int studentTotalScore = chineseScore + englishScore + mathScore + computerScore; //无效
		/// <summary>
		/// 平均
		/// </summary>
		int subjectAverage;
		/// <summary>
		/// 名次
		/// </summary>
		int rankingScore;



	};


	/// <summary>
	/// 语文成绩排序,降  从大到小
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpChineseAsc(GeovinStudent a, GeovinStudent b)
	{
		return a.chineseScore > b.chineseScore;
	}
	/// <summary>
	/// 语文成绩排序,升 从小到大
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpChineseDesc(GeovinStudent a, GeovinStudent b)
	{
		return a.chineseScore < b.chineseScore;
	}

	/// <summary>
	/// 英语成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpEnglishAsc(GeovinStudent a, GeovinStudent b)
	{
		return a.englishScore > b.englishScore;
	}
	/// <summary>
	/// 英语成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpEnglishDesc(GeovinStudent a, GeovinStudent b)
	{
		return a.englishScore < b.englishScore;
	}

	/// <summary>
	/// 数学成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpMathAsc(GeovinStudent a, GeovinStudent b)
	{
		return a.mathScore > b.mathScore;
	}
	/// <summary>
	/// 数学成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpMathDesc(GeovinStudent a, GeovinStudent b)
	{
		return a.mathScore < b.mathScore;
	}


	/// <summary>
	/// 计算机成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpComputerAsc(GeovinStudent a, GeovinStudent b)
	{
		return a.computerScore > b.computerScore;
	}
	/// <summary>
	/// 计算机成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpComputerDesc(GeovinStudent a, GeovinStudent b)
	{
		return a.computerScore < b.computerScore;
	}

	/// <summary>
	/// 个人总分成绩排序,降
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpTotalScoreAsc(GeovinStudent a, GeovinStudent b)
	{
		return a.studentTotalScore > b.studentTotalScore;
	}
	/// <summary>
	/// 个人总分成绩排序,升
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	bool cmpTotalScoreDesc(GeovinStudent a, GeovinStudent b)
	{
		return a.studentTotalScore < b.studentTotalScore;
	}



}



#endif

  

// GeovinStudentSort.cpp : 此文件包含 "GeovinStudentSort" 类。学生数组成绩显示方法 C++ 14
// 2023年4月19日 涂聚文 Geovin Du edit.


#include "GeovinStudentSort.h"
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include <list>
#include <vector> 
#include <memory> 

#include "GeovinStudent.h"

using namespace std;


/**
*
*/
namespace geovindu
{



	/// <summary>
	/// 
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::ChineseAsc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpChineseAsc);
		list = student;
		return list;
	}
	/// <summary>
	/// 
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::ChineseDesc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpChineseDesc);
		list = student;
		return list;
	}

	/// <summary>
	/// 
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::EnlgishAsc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpEnglishAsc);
		list = student;
		return list;
	}
	/// <summary>
	/// 
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::EnlgishDesc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpEnglishDesc);
		list = student;
		return list;
	}


	/// <summary>
	/// 
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::MathAsc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpMathAsc);
		list = student;
		return list;
	}
	/// <summary>
	/// 
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::MathDesc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpMathDesc);
		list = student;
		return list;
	}

	/// <summary>
	/// Computer
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::ComputerAsc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpComputerAsc);
		list = student;
		return list;
	}
	/// <summary>
	/// 
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::ComputerDesc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpComputerDesc);
		list = student;
		return list;
	}


	/// <summary>
	/// TotalScore
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::TotalScoreAsc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpTotalScoreAsc);
		list = student;
		return list;
	}
	/// <summary>
	/// 
	/// </summary>
	/// <param name="student"></param>
	/// <returns></returns>
	vector<GeovinStudent> GeovinStudentSort::TotalScoreDesc(vector<GeovinStudent> student)
	{
		vector<GeovinStudent> list;
		sort(std::begin(student), std::end(student), cmpTotalScoreDesc);
		list = student;
		return list;
	}



}

  以上写法不能引用,引用报错,

 

Automatically Detecting Text Encodings

https://github.com/AutoItConsulting/text-encoding-detect
https://preshing.com/20200727/automatically-detecting-text-encodings-in-cpp/
https://github.com/arc80/plywood
https://learn.microsoft.com/en-us/answers/questions/1058919/automatically-detect-text-file-encoding
https://www.codeproject.com/articles/17201/detect-encoding-for-in-and-outgoing-text

posted @ 2023-04-22 00:31  ®Geovin Du Dream Park™  阅读(47)  评论(0)    收藏  举报