Mohammad A
New member
Hello, can anybody help me solving my programming problem?
how do i return 'arr2' and then call 'arr2' from another function?
Thanks in advance, oh and by the way i'm using Dev-C++
Here is my code...
#include <iostream>
#include <iomanip>
void bhg1();
int main()
{
bhg1();
int a;
scanf(" %d ",a);
return 0;
}
void bhg1()
{
int width, height;
int i,j;
width = height = 13;
unsigned char *arr2 = new unsigned char[width*height];
unsigned char arr1[] =
{
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1
};
for(j=0;j<height;j++)
{
for(i=0;i<width;i++)
{
arr2[j*width+i] = 1;
printf(" %d ", (int)arr1[j*width+i]);
}
printf("\n");
}
float a0,a1,a2,a3;
float b0,b1,b2,b3;
a0 = 0.00;
a1 = 0.0;
a2 = 1.0;
a3 = 0.0;
b0 =0.0;
b1 =1.0;
b2 =0.0;
b3 =0.0;
int padH = 11;
int padW = 11;
float u,v;
for(j=0;j<padH;j++)
{
for(i=0;i<padW;i++)
{
u = (a0*1) + (a1*j) +(a2*i)+(a3*j*i);
v = (b0*1) + (b1*j) +(b2*i)+(b3*j*i);
if (((int)u<width) && ((int)v<height) ) arr2[j*width+i] = arr1[(int)v*width+(int)u];
}
printf("\n");
}
for(j=0;j<height;j++)
{
for(i=0;i<width;i++)
{
printf(" %d ", (int)arr2[j*width+i]);
}
printf("\n");
}
}
how do i return 'arr2' and then call 'arr2' from another function?
Thanks in advance, oh and by the way i'm using Dev-C++
Here is my code...
#include <iostream>
#include <iomanip>
void bhg1();
int main()
{
bhg1();
int a;
scanf(" %d ",a);
return 0;
}
void bhg1()
{
int width, height;
int i,j;
width = height = 13;
unsigned char *arr2 = new unsigned char[width*height];
unsigned char arr1[] =
{
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1,
12, 11, 34, 12, 45, 56, 12, 23, 45, 56, 11,1,1,1
};
for(j=0;j<height;j++)
{
for(i=0;i<width;i++)
{
arr2[j*width+i] = 1;
printf(" %d ", (int)arr1[j*width+i]);
}
printf("\n");
}
float a0,a1,a2,a3;
float b0,b1,b2,b3;
a0 = 0.00;
a1 = 0.0;
a2 = 1.0;
a3 = 0.0;
b0 =0.0;
b1 =1.0;
b2 =0.0;
b3 =0.0;
int padH = 11;
int padW = 11;
float u,v;
for(j=0;j<padH;j++)
{
for(i=0;i<padW;i++)
{
u = (a0*1) + (a1*j) +(a2*i)+(a3*j*i);
v = (b0*1) + (b1*j) +(b2*i)+(b3*j*i);
if (((int)u<width) && ((int)v<height) ) arr2[j*width+i] = arr1[(int)v*width+(int)u];
}
printf("\n");
}
for(j=0;j<height;j++)
{
for(i=0;i<width;i++)
{
printf(" %d ", (int)arr2[j*width+i]);
}
printf("\n");
}
}