/*Write a program that reads in a two-dimensional array representing the coordinates of points in space.
The program should determine the largest absolute value in the array and scale each element of the array by dividing it by this largest value.
The new array, which is called the normalized array, should have the largest value.
The program consists of two functions:
• main() – obtains the number of data points, and the x and y coordinates of each point.
• normalize() – normalize the array.*/
#include<stdio.h>
#include<stdlib.h>
int normalize(int input[][1], int row, int col);
int main()
{
int row1=2;
int col1=2;
int b[1][1];
int ans;
printf("Enter the coordinate of x1:");
scanf("%d",&b[0][0]);
printf("Enter the coordinate of y1:");
scanf("%d",&b[0][1]);
printf("Enter the coordinate of x2:");
scanf("%d",&b[1][0]);
printf("Enter the coordinate of y2:");
scanf("%d",&b[1][1]);
ans=normalize(b[][1],row1,col1);
printf("the highest value is %d",ans);
system("pause");
return 0;
}
int normalize(int input[][1], int row, int col)
{
int i, j;
int highest = input[0][0];
for( i = 0; i < row; i++)
for( j = 0; j < col; j++)
if ( input[i][j] > highest)
highest = input[i][j];
return highest;
}
the problem is at line 'ans=normalize(b[][1],row1,col1);' the compiler said there is an expected value b4 the']'.. but if i put anything there'll be another problem occur. :(
thanks :D
Firstly, edit your post so it uses code tags - the <> button on the right
So it looks like this:
1 2 3 4 5 6 7 8 9 10 11 12
int normalize(int input[][1], int row, int col)
{
int i, j;
int highest = input[0][0];
for( i = 0; i < row; i++)
for( j = 0; j < col; j++)
if ( input[i][j] > highest)
highest = input[i][j];
return highest;
}
If you have any compiler errors post those in full as well
C:\Users\user\Desktop\1128541AssLab3.cpp In function `int main()':
26 C:\Users\user\Desktop\1128541AssLab3.cpp expected primary-expression before ']' token