数据结构:实验二
来源:互联网 发布:unity3d导出obj 编辑:程序博客网 时间:2024/05/29 16:54
// 实验二.cpp :///*1.定义student结构体,包含姓名、学号、C成绩、VB成绩、数学成绩和英语成绩,并计算平均成绩,通过调用函数输出平局成绩。2.函数完成二维数组的最小值查找,并在主函数中输出(用指针实现)。*/#include "stdafx.h"#include "string"#include "iostream"using namespace std;//score structstruct score{ int c; int vb; int math; int music;};//student structstruct student{ string name; int num; struct score score; float aver;}stu;//Input and Output Function(First question )void inOutPut1(struct student stu){ cout << "Input Name:"; cin >> stu.name; cout << "Input Number:"; cin >> stu.num; cout << "Input C score:"; cin >> stu.score.c; cout << "Input VB score:"; cin >> stu.score.vb; cout << "Input Math score:"; cin >> stu.score.math; cout << "Input Music score:"; cin >> stu.score.music; float anvagerScore = (stu.score.c + stu.score.vb + stu.score.math + stu.score.music)/4.0; cout << "anvagerScore:"; cout << anvagerScore; cout << "\n";}//Find Min Value(Second question)int min(int (*p)[2]){ int min = (*p)[0]; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) if ((*(p + i))[j] < min) min = (*(p + i))[j]; return min;}//Input and Output Function(Second question )void inOutPut2(){ int(*p)[2];//two-dimensional array point,equivalent to int [][2] int arr[2][2];//two-dimensional array for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) cin >> arr[i][j];//input elements p = arr;//point to the arr's first(arr[0][0]) element address cout << "min="; cout << min(&p[0]);//output min vaule cout << "\n";}int main(){ // inOutPut1(stu); inOutPut2();}
first output:
second output:
0 0
- 数据结构实验二
- 数据结构:实验二
- 《数据结构 实验二》
- 数据结构实验二
- 《数据结构》实验二:线性表的实验
- 《数据结构》实验二:线性表实验
- 《数据结构》实验二: 线性表实验
- 《数据结构》实验二 线性表的实验
- 《数据结构》实验二:线性表实验
- 《数据结构》实验二:线性表的实验
- 数据结构实验二 :线性表的实验
- 《数据结构》实验二 线性表的实验
- 《数据结构》实验二:线性表实验(1)
- 数据结构实验二 线性表实验
- 《数据结构》实验二: 线性表实验
- 《数据结构》实验二:线性表的实验
- 《数据结构》实验二:线性表的实验
- 《数据结构》实验二: 线性表实验
- leecode 第一题 TWO SUM
- 《剑指offer》—1、二维数组中的查找
- 贪心算法-翻硬币
- 合并顺序表A和B,并且升序排序 到&Lc
- edittext的长度过长,给提示
- 数据结构:实验二
- Spring配置中各个jar的作用详解
- PAT 1118 Birds in Forest
- servlet表单数据
- Android 获取assets的绝对路径
- PyHusky快速开始
- 常见的20种“瓶颈”(性能问题)
- node-webkit制作桌面应用
- C#使用 Salt + Hash 来为密码加密