PLEASE I NEED HELP ON MY HOMEWORK

http://tinyurl.com/p8lxjn6 its my homework link and I tried to do my homework but I couldnt :( so please fix my homework or give me an idea to new one I have short time please

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  #include <stdio.h>
#include <stdlib.h>

int satir,sütun;

int main(int argc, char *argv[])
{
satir=atoi(argv[1]);
sütun=atoi(argv[2]);
int i,j,array[satir][sütun];

for(i=0 ; i<argc ; i++)
  {
   for(j=0 ; j<argc ; j++)
    {
    array[i][j]=atoi(argv[3+(sütun*i)+j]);
    }
  }

  if((i%4==0 && j%4==1 && (array[i][j]=array[i][j-1]+array[i][j+1]+array[i+1][j]+array[i-1][j])) && (i%4==0 && j%4==3 && (array[i][j]=array[0][j-1]*array[i][j+1]*array[i+1][j]*array[i-1][j])) && (i%4==1 && j%4==0 && (array[i][j]=array[i][j+1]*array[i-1][j]*array[i+1][j])) && (i%4==1 && j%4==2 && (array[i][j]=array[i][j-1]+array[i][j+1]+array[i-1][j]+array[i+1][j])) && (i%4==2 && j%4==1 && (array[i][j]=array[i][j+1]*array[i][j-1]*array[i+1][j]*array[i-1][j])) && (i%4==2 && j%4==3 && (array[i][j]=array[i][j+1]+array[i][j-1]+array[i+1][j]+array[i-1][j])) && (i%4==3 && j%4==0 && (array[i][j]=array[i][j+1]+array[i+1][j]+array[i-1][j])) && (i%4==3 && j%4==2 && (array[i][j]=array[i][j+1]*array[i][j-1]*array[i+1][j]*array[i-1][j]))
  ){
printf("ACCEPTABLE");
}
else{
printf("NOT MATCH");
}

system("pause");
return 0;

}
cant read 20th line. can you format it?
first write program to take the input from user. use a 2D array to cin values.
At some point you should have stopped and questioned what were you doing in line 20.
You need to understand the pattern, it swaps from + to *, so you can have
1
2
3
4
5
6
7
8
bool is_plus = true;
//when reaching an "event cell"
if( is_plus )
   check_sum( matrix, row, column );
else
   check_product( matrix, row, column );

is_plus = not is_plus;


The order of the checks is irrelevant, so you may do all the odd rows first (you know that the operation would change columns/2 times between rows), and just jump out of the empty cell
1
2
3
for(int K=0; K<rows; K+=2) //odds rows
   for(int L=1; L<columns; L+=2) //the event start in the second column
      //... 



Be careful to with the borders, make sure to check that the indexes are valid.
Last edited on
it can be done by both 1D and 2D array.
Also, your code to input the array on line 12-18 is wrong. It should be:
1
2
3
4
5
6
7
for(i=0 ; i<satir; i++)
  {
   for(j=0 ; j<sütun; j++)
    {
    array[i][j]=atoi(argv[3+(sütun*i)+j]);
    }
  }
Last edited on
Topic archived. No new replies allowed.