先通过一个二维数组保存学生相关的信息
为了更直观的观看,决定用字符串数组来保存数据
当然在计算的时候要转变格式,
// 实验十二 数组(二维).cpp: 定义控制台应用程序的入口点。 #include "stdafx.h" #include<iostream> using namespace std; #include<string> int main() { string a[4][5] = { {"生","号","语","数","英"} ,{"A ","01","80","85","96"},{"B ","02","72","90","89"},{"c ","03","78","86","88"} }; cout << "当前成绩表如下:"<<endl; for (int i = 0; i < 6; i++) { for (int j = 0; j < 5; j++) { cout << a[i][j] << " "; } cout << endl; } return 0; }
输出结果如下:
当前成绩表如下:
生 号 语 数 英
A 01 80 85 96
B 02 72 90 89
c 03 78 86 88
请按任意键继续. . .
首先尝试用强制转换类型来将字符串型转换为整型便 写了下面的代码
int a[1][2], a[2][2], a[3][2];
但是发现并没有什么卵用
然后又想到了.......什么也没想到
再然后当然去百度啦
百度发现是可以用指针来实现类型的转换的
那么具体怎么做呢
.....................................
半个小时过去后
并没有发现什么
................................
两个小时过后仍没找到办法
最后写出来的这个程序居然有点小问题
原文:https://www.cnblogs.com/ldddbk/p/9127587.html