請建立一個student class
成員有:name(string), math(int), java(int), OS(int)
建構方法
方法有:print(), average()
main 中宣告一個3個student的陣列(用普通C陣列即可)
實作average()方法算 math, java, OS 的平均
利用print方法輸出這3個student的資料(含分數平均)
並依據math, java, OS, average()列出四種排序結果
herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
XOR prefixsum CPP python解Leetcode 1829 Maximum XOR for Each Query 其實這裡考慮的是元素個數為2^maximumBit的交換群,運算子為XOR。 [Python code請進]
-
你會用C的算子sizeof?
-
Python C++使用字串find迴圈速解Leetcode 2490 Circular Sentence C++ & Python都有字串的find,用法都類似 split=s.find(' ', split+1)能找到s從index=split+1開...
-
先說明一下這是後知後覺的解答,所謂後知就是股票價格已知存在陣列(清單),當然就要用迴圈練習,雙迴圈暴力解需時O(n**2),當然不用,採python單一迴圈解答「最佳股票的買賣時機#LeetCode 121 Best Time to Buy and Sell Stock」,解...
-
Colab上安裝中文字型修改股市爬蟲pyplot顯圖 使用python套件: numpy, requests. pyplot, matplotlib.font_manager, matplotlib.mpl
-
2 pointer Python C++解Leetcode 3163 String Compression III [codes on Leetcode] https://leetcode.com/problems/string-compression-iii/solution...
29 則留言:
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
double av;
student(){}
student(string x,int y,int z,int w ){
name = x;
math = y;
java = z;
OS = w;
av = (y + z + w) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t 平均=" << av << endl;
}
};
int main()
{
student X = student("A", 52, 60, 70);
student Y = student("B", 80, 70, 55);
student Z = student("C", 74, 59, 98);
X.print();
Y.print();
Z.print();
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x,int y,int z,int w){
name = x;
math = y;
java = z;
OS = w;
}
double avg(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS <<"\t avg="<<avg()<<endl;
}
};
int main()
{
student x[3];
x[0] = student("你好不好", 20, 40, 50);
x[0].print();
x[1] = student("我好不好", 50, 30, 60);
x[1].print();
x[2] = student("他好不好", 100, 90, 95);
x[2].print();
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double avg(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java="<< java << "\t OS=" << OS << "\t avg="<<avg()<<endl;
}
};
int main(){
{
student x[3];
x[0] = student("牠好不好", 90, 80, 70);
x[0].print();
x[1] = student("她好不好", 70, 60, 80);
x[1].print();
x[2] = student("他好不好", 100, 50, 80);
x[2].print();
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double avg(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS <<"\t avg="<<avg()<< "\n";
}
};
bool mathbigger(student x,student y){
return x.math > y.math;
}
int main(){
student X[3];
X[0] = student("B10333054",80, 73, 89);
X[0].print();
X[1] = student("B10333049",94, 83,79);
X[1].print();
X[2] = student("B10333016",80,78,100);
X[2].print();
sort(X, X + 3, mathbigger);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
double av;
student(){}
student(string x,int y,int z,int w ){
name = x;
math = y;
java = z;
OS = w;
av = (y + z + w) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t 平均=" << av << endl;
}
};
bool mathBigger(student X , student Y)
{
return X.math > Y.math;
}
bool javaBigger(student X, student Y)
{
return X.java > Y.java;
}
bool OSBigger(student X, student Y)
{
return X.OS > Y.OS;
}
bool avBigger(student X, student Y)
{
return X.av > Y.av;
}
void printALL(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("A", 52, 60, 70);
X[1] = student("B", 80, 70, 55);
X[2] = student("C", 74, 59, 98);
printALL(X);
cout << "=====math======\n";
sort(X, X + 3, mathBigger);
for (student a : X)
a.print();
cout << "=====java======\n";
sort(X, X + 3, javaBigger);
for (student a : X)
a.print();
cout << "=====OS======\n";
sort(X, X + 3, OSBigger);
for (student a : X)
a.print();
cout << "=====av======\n";
sort(X, X + 3, avBigger);
for (student a : X)
a.print();
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int os;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
os = w;
}
double j(){
return (math + java + os) / 3.00;
}
void print()
{
cout << name << "\t math=" << math << "\t java="
<< java << "\t os=" << os << "\t 平均="<<j()<< "\n";
}
};
bool javaBigger(student X, student Y){
return X.java > Y.java;
}
bool mathBigger(student X, student Y){
return X.math > Y.math;
}
bool osBigger(student X, student Y){
return X.os > Y.os;
}
bool Bigger(student X, student Y){
return X.j() > Y.j();
}
int main()
{
student x[3];
x[0] = student("地平線", 70, 60, 50);
x[1] = student("歡樂天堂", 76, 85, 97);
x[2] = student("補習地獄", 42, 59, 34);
for (int i = 0; i < 3; i++)
{
x[i].print();
}
cout << "==========java===========" << "\n";
sort(x, x + 3, javaBigger);
for (int i = 0; i < 3; i++)
{
x[i].print();
}
cout << "==========math===========" << "\n";
sort(x, x + 3, mathBigger);
for (int i = 0; i < 3; i++)
{
x[i].print();
}
cout << "==========os===========" << "\n";
sort(x, x + 3, osBigger);
for (int i = 0; i < 3; i++)
{
x[i].print();
}
cout << "==========平均數===========" << "\n";
sort(x, x + 3, Bigger);
for (int i = 0; i < 3; i++)
{
x[i].print();
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string z,int x,int c,int v){
name = z; math = x; java = c; OS = v;
}
void print()
{
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS<<"\t 平均="<<and()<<"\n";
}
double and()
{
return( (math + java + OS) / 3.0);
}
};
bool mathBigger(student x, student y)
{
return x.math > y.math;
}
bool javaBigger(student x, student y)
{
return x.java > y.java;
}
bool OSBigger(student x, student y)
{
return x.OS > y.OS;
}
bool avBigger(student x, student y)
{
return x.and() > y.and();
}
void all(student x[3])
{
for (int i = 0; i < 3; i++)
{
x[i].print();
}
}
int main()
{
student x[3];
x[0] = student("哈瞜", 75, 80, 90);
x[1] = student("你好", 80, 70, 60);
x[2] = student("世界", 60, 80, 65);
all(x);
cout << "--------Math-----------" << "\n";
sort(x, x + 3, mathBigger);
all(x);
cout << "--------java-----------" << "\n";
sort(x, x + 3, javaBigger);
all(x);
cout << "---------OS----------" << "\n";
sort(x, x + 3, OSBigger);
all(x);
cout << "--------平均---------" << "\n";
sort(x, x + 3, avBigger);
all(x);
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java
<< "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printlAll(X);
cout << "-----------math排--------\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java
<< "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printlAll(X);
cout << "-----------math排--------\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java
<< "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printlAll(X);
cout << "-----------math排--------\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java
<< "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printlAll(X);
cout << "-----------math排--------\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java
<< "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printlAll(X);
cout << "-----------math排--------\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java
<< "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printlAll(X);
cout << "-----------math排--------\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java
<< "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printlAll(X);
cout << "-----------math排--------\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("王小明", 67, 88, 76);
X[1] = student("陳小華", 83, 67, 68);
X[2] = student("黃少洋", 87, 87, 63);
printlAll(X);
cout << "===========math排============\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return(math + java + OS) / 3.0;
};
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
bool javaBigger(student X, student Y)
{
return X.math > Y.math;
}
bool OSBigger(student X, student Y)
{
return X.math > Y.math;
}
void printAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printAll(X);
cout << "===========math排=================\n";
sort(X, X + 3, mathBigger);
printAll(X);
cout << "===========java排=================\n";
sort(X, X + 3, javaBigger);
printAll(X);
cout << "===========OS排=================\n";
sort(X, X + 3, OSBigger);
printAll(X);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double avg(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t avg=" << avg() << "\n";
}
};
bool mathbigger(student x, student y){
return x.math > y.math;
}
bool javabigger(student x, student y){
return x.java > y.java;
}
bool OSbigger(student x, student y){
return x.OS > y.OS;
}
bool bigger(student x, student y){
return x.avg() > y.avg();
}
void printAll(student x[3]){
for (int i = 0; i < 3; i++)
x[i].print();
}
int main(){
student X[3];
X[0] = student("B10533065", 81, 73, 88);
X[0].print();
X[1] = student("B10533070", 59, 47, 69);
X[1].print();
X[2] = student("B10533066", 51, 59, 62);
X[2].print();
cout << "==============math==============\n";
sort(X, X + 3, mathbigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "==============java==============\n";
sort(X, X + 3, javabigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "==============os==============\n";
sort(X, X + 3, OSbigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "==============平均==============\n";
sort(X, X + 3, bigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double avg(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t avg=" << avg() << "\n";
}
};
bool mathbigger(student x, student y){
return x.math > y.math;
}
bool javabigger(student x, student y){
return x.java > y.java;
}
bool OSbigger(student x, student y){
return x.OS > y.OS;
}
bool bigger(student x, student y){
return x.avg() > y.avg();
}
void printAll(student x[3]){
for (int i = 0; i < 3; i++)
x[i].print();
}
int main(){
student X[3];
X[0] = student("B10533065", 81, 73, 88);
X[0].print();
X[1] = student("B10533070", 59, 47, 69);
X[1].print();
X[2] = student("B10533066", 51, 59, 62);
X[2].print();
cout << "==============math==============\n";
sort(X, X + 3, mathbigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "==============java==============\n";
sort(X, X + 3, javabigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "==============os==============\n";
sort(X, X + 3, OSbigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "==============平均==============\n";
sort(X, X + 3, bigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include<algorithm>
using namespace std;
int main();
class student
{
public:
string name;
int math;
int java;
int os;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
os = w;
}
double av(){
return(math + java + os) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t os" << os
<< "\t av="<<av()<< "\n ";
}
};
bool bigger(int x, int y)
{
return x > y;
}
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
bool javaBigger(student X, student Y)
{
return X.java > Y.java;
}
bool osBigger(student X, student Y)
{
return X.os > Y.os;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
cout << " ==========================================================\n";
student X[3];
X[0] = student(" 東", 67, 88, 76);
X[1] = student("西", 96, 78, 56);
X[2] = student("南", 66, 50, 77);
printlAll(X);
cout << "============================math==========================\n";
printlAll(X);
cout << "============================java==========================\n";
printlAll(X);
cout << "============================os============================\n";
printlAll(X);
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return(math + java + OS) / 3.0;
};
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
bool javaBigger(student X, student Y)
{
return X.math > Y.math;
}
bool OSBigger(student X, student Y)
{
return X.math > Y.math;
}
void printAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printAll(X);
cout << "===========math排=================\n";
sort(X, X + 3, mathBigger);
printAll(X);
cout << "===========java排=================\n";
sort(X, X + 3, javaBigger);
printAll(X);
cout << "===========OS排=================\n";
sort(X, X + 3, OSBigger);
printAll(X);
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int os;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
os = w;
}
double av(){
return (math + java + os) / 3.0;
}
void print(){
cout<< name << "\t math=" << math << "\t java=" << java
<< "\t os=" << os << "\t av="<< av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
bool osBigger(student X, student Y)
{
return X.os > Y.os;
}
bool javaBigger(student X, student Y)
{
return X.java > Y.java;
}
bool avBigger(student X, student Y)
{
return X.av() > Y.av();
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[1].print();
}
int main()
{
student X[3];
X[0] = student("你好不好", 60, 88, 76);
X[1] = student("....", 50, 40, 30);
X[2] = student("123", 80, 70, 60);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
cout << "-----math-------\n";
sort(X, X + 3, mathBigger);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
cout << "-----os-------\n";
sort(X, X + 3, osBigger);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
cout << "-----java-------\n";
sort(X, X + 3, javaBigger);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
cout << "-----av-------\n";
sort(X, X + 3, avBigger);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" < Y.math;
}
bool javaBigger(student X, student Y)
{
return X.java > Y.java;
}
bool OSBigger(student X, student Y)
{
return X.OS > Y.OS;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 67, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "============math排============\n";
sort(X, X + 3, mathBigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "============java排============\n";
sort(X, X + 3, javaBigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
cout << "============OS排============\n";
sort(X, X + 3, OSBigger);
for (int i = 0; i < 3; i++){
X[i].print();
}
system("Pause");
return 0;
}
#include
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java
<< "\t OS=" << OS << "\t av=" << av() << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
void printlAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printlAll(X);
cout << "-----------math排--------\n";
sort(X, X + 3, mathBigger);
printlAll(X);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double av(){
return(math + java + OS) / 3.0;
};
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\n";
}
};
bool mathBigger(student X, student Y)
{
return X.math > Y.math;
}
bool javaBigger(student X, student Y)
{
return X.math > Y.math;
}
bool OSBigger(student X, student Y)
{
return X.math > Y.math;
}
void printAll(student X[3]){
for (int i = 0; i < 3; i++)
X[i].print();
}
int main()
{
student X[3];
X[0] = student("你好不", 68, 88, 76);
X[1] = student("1號", 96, 78, 56);
X[2] = student("2號", 66, 50, 77);
printAll(X);
cout << "----------------math排--------------\n";
sort(X, X + 3, mathBigger);
printAll(X);
cout << "---------------java排----------\n";
sort(X, X + 3, javaBigger);
printAll(X);
cout << "--------OS排--------\n";
sort(X, X + 3, OSBigger);
printAll(X);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
student(){}
student(string x, int y, int z, int w){
name = x;
math = y;
java = z;
OS = w;
}
double avg(){
return (math + java + OS) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS <<"\t avg="<<avg()<< "\n";
}
};
bool mathbigger(student X,student Y){
return X.math >Y.math;
}
bool javabigger(student X, student Y){
return X.java >Y.java;
}
bool OSbigger(student X, student Y){
return X.OS >Y.OS;
}
bool avgbigger(student X, student Y){
return X.avg() >Y.avg();
}
int main(){
student X[3];
X[0] = student("B10333054",85, 73, 89);
X[0].print();
X[1] = student("B10333049",94, 83,79);
X[1].print();
X[2] = student("B10333016",80,78,100);
X[2].print();
cout << "-----math-------\n";
sort(X, X + 3, mathbigger);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
cout << "-----java-------\n";
sort(X, X + 3, javabigger);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
cout << "-----OS-------\n";
sort(X, X + 3, OSbigger);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
cout << "-----avg-------\n";
sort(X, X + 3, avgbigger);
for (int i = 0; i < 3; i++)
{
X[i].print();
}
system("Pause");
return 0;
}
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
double av;
student(){}
student(string x,int y,int z,int w ){
name = x;
math = y;
java = z;
OS = w;
av = (y + z + w) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t 平均=" << av << endl;
}
};
int main()
{
student X = student("A", 52, 60, 70);
student Y = student("B", 80, 70, 55);
student Z = student("C", 74, 59, 98);
X.print();
Y.print();
Z.print();
system("Pause");
return 0;
}
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
double av;
student(){}
student(string x,int y,int z,int w ){
name = x;
math = y;
java = z;
OS = w;
av = (y + z + w) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t 平均=" << av << endl;
}
};
int main()
{
student X = student("A", 52, 60, 70);
student Y = student("B", 80, 70, 55);
student Z = student("C", 74, 59, 98);
X.print();
Y.print();
Z.print();
system("Pause");
return 0;
}
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
double av;
student(){}
student(string x,int y,int z,int w ){
name = x;
math = y;
java = z;
OS = w;
av = (y + z + w) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t 平均=" << av << endl;
}
};
int main()
{
student X = student("A", 52, 60, 70);
student Y = student("B", 80, 70, 55);
student Z = student("C", 74, 59, 98);
X.print();
Y.print();
Z.print();
system("Pause");
return 0;
}
#include
#include
#include
using namespace std;
class student
{
public:
string name;
int math;
int java;
int OS;
double av;
student(){}
student(string x,int y,int z,int w ){
name = x;
math = y;
java = z;
OS = w;
av = (y + z + w) / 3.0;
}
void print(){
cout << name << "\t math=" << math << "\t java=" << java << "\t OS=" << OS << "\t 平均=" << av << endl;
}
};
int main()
{
student X = student("A", 52, 60, 70);
student Y = student("B", 80, 70, 55);
student Z = student("C", 74, 59, 98);
X.print();
Y.print();
Z.print();
system("Pause");
return 0;
}
張貼留言