View Code of Problem 17

#include <stdio.h>
int cil(int a[1000][1000],int i,int j);
int main(){
	int step,i,j,m,n,max=0;
	while(~scanf("%d %d",&n,&m)){
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",a[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			step=cil(a,i,j);
			if(step>max)
			max=step;
		}
	}
	printf("\n");
  } 
int cil(int a[1000][1000],int i,int j){
	int a=b=c=d=0;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
	return 0;
	else {
	if(a[i][j]<a[i+1][j]) a=cil(a,i+1,j)+1;
	if(a[i][j]<a[i-1][j]) a=cil(a,i-1,j)+1;	
	if(a[i][j]<a[i][j+1]) a=cil(a,i,j+1)+1;
	if(a[i][j]<a[i][j-1]) a=cil(a,i,j-1)+1;		
}
    return (a>b?a:b)>(c>d?c:d)?(a>b?a:b):(c>d?c:d); 
}
}
/*
Main.c: In function 'main':
Main.c:8:15: error: 'a' undeclared (first use in this function)
    scanf("%d",a[i][j]);
               ^
Main.c:8:15: note: each undeclared identifier is reported only once for each function it appears in
Main.c: In function 'cil':
Main.c:21:6: error: 'a' redeclared as different kind of symbol
  int a=b=c=d=0;
      ^
Main.c:20:13: note: previous definition of 'a' was here
 int cil(int a[1000][1000],int i,int j){
             ^
Main.c:21:8: error: 'b' undeclared (first use in this function)
  int a=b=c=d=0;
        ^
Main.c:21:10: error: 'c' undeclared (first use in this function)
  int a=b=c=d=0;
          ^
Main.c:21:12: error: 'd' undeclared (first use in this function)
  int a=b=c=d=0;
            ^
Main.c:23:6: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
      ^
Main.c:23:14: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
              ^
Main.c:23:25: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
                         ^
Main.c:23:33: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
                                 ^
Main.c:23:44: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
                                            ^
Main.c:23:52: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
                                                    ^
Main.c:23:63: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
                                                               ^
Main.c:23:71: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]>a[i+1][j]&&a[i][j]>a[i-1][j]&&a[i][j]>a[i][j+1]&&a[i][j]>a[i][j-1])
                                                                       ^
Main.c:26:6: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]<a[i+1][j]) a=cil(a,i+1,j)+1;
      ^
Main.c:26:14: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]<a[i+1][j]) a=cil(a,i+1,j)+1;
              ^
Main.c:26:30: warning: passing argument 1 of 'cil' makes pointer from integer without a cast
  if(a[i][j]<a[i+1][j]) a=cil(a,i+1,j)+1;
                              ^
Main.c:20:5: note: expected 'int (*)[1000]' but argument is of type 'int'
 int cil(int a[1000][1000],int i,int j){
     ^
Main.c:27:6: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]<a[i-1][j]) a=cil(a,i-1,j)+1; 
      ^
Main.c:27:14: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]<a[i-1][j]) a=cil(a,i-1,j)+1; 
              ^
Main.c:27:30: warning: passing argument 1 of 'cil' makes pointer from integer without a cast
  if(a[i][j]<a[i-1][j]) a=cil(a,i-1,j)+1; 
                              ^
Main.c:20:5: note: expected 'int (*)[1000]' but argument is of type 'int'
 int cil(int a[1000][1000],int i,int j){
     ^
Main.c:28:6: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]<a[i][j+1]) a=cil(a,i,j+1)+1;
      ^
Main.c:28:14: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]<a[i][j+1]) a=cil(a,i,j+1)+1;
              ^
Main.c:28:30: warning: passing argument 1 of 'cil' makes pointer from integer without a cast
  if(a[i][j]<a[i][j+1]) a=cil(a,i,j+1)+1;
                              ^
Main.c:20:5: note: expected 'int (*)[1000]' but argument is of type 'int'
 int cil(int a[1000][1000],int i,int j){
     ^
Main.c:29:6: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]<a[i][j-1]) a=cil(a,i,j-1)+1;  
      ^
Main.c:29:14: error: subscripted value is neither array nor pointer nor vector
  if(a[i][j]<a[i][j-1]) a=cil(a,i,j-1)+1;  
              ^
Main.c:29:30: warning: passing argument 1 of 'cil' makes pointer from integer without a cast
  if(a[i][j]<a[i][j-1]) a=cil(a,i,j-1)+1;  
                              ^
Main.c:20:5: note: expected 'int (*)[1000]' but argument is of type 'int'
 int cil(int a[1000][1000],int i,int j){
     ^
*/

Double click to view unformatted code.


Back to problem 17