各位大佬给我看看呗
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;
}