#include <iostream>
#include <fstream>
using namespace std;
class change_TAB
{
private:
fstream fp1;
fstream fp2;
int **tab1;
int **tab2;
int width;
int height;
int ss;
char *f1,*f2;
public:
change_TAB(char* file_Start, char* file_End, int x, int y, int s)
{
int i;
width=x;
height=y;
ss=s;
f1=file_Start;
f2=file_End;
tab1=new int *[width];
tab2=new int *[width];
for(i=0;i<width;i++)
{
tab1[i]=new int[height];
tab2[i]=new int[height];
}
}
~change_TAB()
{
int i;
for(i=0;i<width;i++)
{
delete [] tab1[i];
delete [] tab2[i];
}
delete [] tab1;
delete [] tab2;
}
void Read()
{
int i,j;
fp1.open(f1,ios::in);
for(i=0;i<width;i++)
for(j=0;j<height;j++)
fp1>>tab1[i][j];
fp1.close();
}
void Write()
{
int i,j;
for(i=0;i<width;i++)
for(j=0;j<height;j++)
tab2[i][j]=tab1[i][j]*ss;
fp2.open(f2,ios::out);
for(i=0;i<width;i++)
{
for(j=0;j<height;j++)
{
fp2<<tab2[i][j]<<" ";
}
fp2<<'\n';
}
fp2.close();
}
};
int main()
{
change_TAB TABLES("old_Tab","new_Tab",100,200,5);
TABLES.Read();
TABLES.Write();
return 0;
}
YOU CAN PAY ME - https://paypal.me/LukaszW77?locale.x=pl_PL
Brak komentarzy:
Prześlij komentarz