這個沒錯誤但是沒結果
#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;
}
uj5u.com熱心網友回復:
貌似矩陣加法,大量資料輸入的時候,可以重定向從文本檔案輸入,減少重復作業。uj5u.com熱心網友回復:
什么叫沒有結果轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/44221.html
標籤:基礎類
上一篇:c++ 新人編程
