[ create a new paste ] login | about

Link: http://codepad.org/wGMMPaaD    [ raw code | output | fork ]

yifan666 - C, pasted on Aug 10:
// ladder2
#include <stdio.h>

int main()
{
	int test_case, N;
	int a[100][100];
	freopen("lader2.txt","r", stdin);

	for(test_case=0; test_case<10; test_case++)
	{
		int i = 0; int j= 0;
		scanf("%d", &N);
		
		for(i = 0; i<100; i++){
			for(j=0; j<100; j++){
				scanf("%d", &a[i][j]);
			}			
		}
		
		int min = 10000;
		int c;
		
		for(j = 0; j<100; j++){
		//	printf("a =  %d j= %d\n", a[0][j], j);
			if(a[0][j] == 1){
		//		printf(" j= %d\n", j);	
				int count = 0;
				int k = j;
				i = 0;
				while(i<99){				
					if(a[i][k-1]==1 && k-1>=0){
						while(a[i][k-1]==1 && k-1>=0){
							k--;
							count++;
						}
					}else if(a[i][k+1] == 1 && k+1<=99){
						while(a[i][k+1] == 1 && k+1<=99){
							k++;
							count++;
						}
					}
					i++;
					
				}
	//			printf("count =  %d k= %d\n", count, k);
//				if(min = -1){
//					min = count;
//					c = k;
//				}else 
				if(count < min ){
					min = count;
					c = j;
				}
			}	n
		}
		

		
			
		printf("#%d min= %d, x= %d\n", test_case+1, min, c);
		
		
	
	}
	return 0;
}


Output:
1
2
3
4
5
In function 'main':
Line 55: error: 'n' undeclared (first use in this function)
Line 55: error: (Each undeclared identifier is reported only once
Line 55: error: for each function it appears in.)
Line 56: error: expected ';' before '}' token


Create a new paste based on this one


Comments: