各位大佬给我看看呗

C或P 2018-12-14 07:20:44
这个没错误但是没结果 #include<iostream> #include<cstdlib> #include<ctime> using namespace std; class Myclass { public: int x = 0, y = 0; Myclass(){} void array() { int i = 0, j = 0; do { cin >> a[i][j]; j++; y = j; if (j % 3 == 0) { i++; x = i; } } while (a[i][j]!=EOF); } Myclass(int i, int j) { srand(int(time(0))); for (int o=0; o<i; o++) { for (int p=0; p<j;p++) b[o][p] = rand() % +100; } } Myclass operator+(Myclass&none) { Myclass in; for (int i = 0; i < x; i++) { for (int j=0; j < y; j++) { in.c[i][j] = a[i][j] + b[i][j]; } } return in; } void show() { for (int p = 0; p < x; p++) { for (int o = 0; o < y; o++) { cout << c[p][o]; } cout << endl; } } private: int a[20][20], b[20][20],c[20][20]; }; int main() { Myclass one; cout << "please input one array:" << endl; one.array(); Myclass two(one.x, one.y); Myclass three; three = one + two; three.show(); return 0; }
...全文
174 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
波叔(gaobo) 2018-12-18
  • 打赏
  • 举报
回复
什么叫没有结果
ooolinux 2018-12-14
  • 打赏
  • 举报
回复
貌似矩阵加法,大量数据输入的时候,可以重定向从文本文件输入,减少重复工作。

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧