自己敲的:
標準答案:#include
using namespace std;
#include
struct student
;struct teacher
;string cinteacher01(
)string cinstudent01(
)int cinstudent02(
)int main(
) cout << endl;
}for
(int i = 0; i < 3; i++)
cout << endl;
}return 0;
}
結構體陣列作函式引數相當於位址傳遞。string字串單個輸出的時候就是類似陣列單個輸出,所以string字串可以理解為char陣列#include
using namespace std;
#include
#include
struct student
;struct teacher
;//給老師和學生賦值的函式
void allocatespace(struct teacher tarray[
], int len)}}
//列印所有資訊
void printinfo(struct teacher tarray[
], int len)}}
int main(
)
bilibiliC 70結構體 結構體案例1
8.8.1 案例1 案例描述 學校正在做畢設專案,每名老師帶領5個學生,總共有3名老師,需求如下 設計學生和老師的結構體,其中在老師的結構體中,有老師姓名和乙個存放5名學生的陣列作為成員 學生的成員有姓名 考試分數,建立陣列存放3名老師,通過函式給每個老師及所帶的學生賦值 最終列印出老師資料以及老師...
結構體案例
案例1 案例描述 學校正在做畢設專案,每名老師帶領5個學生,總共有3名老師,需求如下 設計學生和老師的結構體,其中在老師的結構體中,有老師姓名和乙個存放5名學生的陣列作為成員 學生的成員有姓名 考試分數,建立陣列存放3名老師,通過函式給每個老師及所帶的學生賦值 最終列印出老師資料以及老師所帶的學生資...
結構體案例 C
題意 有3名老師,含關鍵字姓名和學生。每位老師帶5名學生,含姓名和分數。使用結構體表示,並列印出資訊。include include includeusing namespace std 定義學生結構體 struct student struct teacher 給老師和學生賦值的函式 void a...