Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int bai2()
- {
- int gate = 0;
- int i,j;
- int x,y;
- FILE *f;
- f = fopen("data1.txt", "r");
- if (f == NULL)
- {
- printf("ERROR\n");
- }
- else
- {
- fscanf(f, "%d", &n);
- }
- for (i = 1; i <= n; i++)
- {
- for (j = 1; j <= n; j++)
- {
- fscanf(f, "%d", &matrix[i][j]);
- printf("map[%d][%d] = %d\n", i, j, matrix[i][j]);
- }
- }
- for(y=0; y<n; y++){
- if(matrix[1][1] == 0)
- gate = gate - 2;
- if(matrix[1][6] == 0)
- gate = gate - 2;
- if(matrix[1][y] == 0)
- gate = gate +1;
- if(matrix[6][y] == 0)
- gate = gate +1;
- }
- for(x=0; x<n; x++){
- if(matrix[1][1] == 0)
- gate = gate + 1;
- if(matrix[6][1] == 0)
- gate = gate + 1;
- if(matrix[x][1] == 0)
- gate = gate +1;
- if(matrix[x][6] == 0)
- gate = gate +1;
- }
- printf("%d\n", gate);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment