- #include<stdio.h>
- int main()
- {
- int mat[5][5], i , j, l, count = 0 , m, n;
- for(i = 0; i < 5; i++){
- for(j = 0; j < 5; j++){
- scanf("%d", &mat[i][j]);
- }
- }
- for(i = 0; i < 5; i++){
- for(j = 0; j < 5 ; j++){
- if(mat[i][j] == 1){
- m = i;
- n = j;
- break;
- }
- }
- }
- for( l = 0; l < 5; l++){
- if( n > 2){
- n = n - 1;
- count++;
- }
- else if (n == 2){
- break;
- }
- else if( n < 2){
- n = n + 1;
- count++;
- }
- }
- for( l = 0; l < 5; l++){
- if( m > 2){
- m = m - 1;
- count++;
- }
- else if (m == 2){
- break;
- }
- else if( m < 2){
- m = m + 1;
- count++;
- }
- }
- printf("%d\n", count);
- return 0;
- }
Tuesday, January 21, 2020
Codeforces 263A Beautiful Matrix Solution in C
Subscribe to:
Post Comments (Atom)
Codeforces 131A cAPS lOCK Solution in C
#include <stdio.h> int main () { char ch [ 106 ]; int i , j , ck = 1 ; scanf ( "%s" , ch ); ...
-
#include <stdio.h> int main () { int o , n , a , b , c , s , t , u ; s = 0 ; t = 0 ; u = 0 ...
-
#include <stdio.h> #include <string.h> int main () { int i , n , l = 0 ; char a [ 120 ]; scanf ( ...
-
#include <stdio.h> #include <string.h> int main () { int i , n , p = 0 ; char s [ 120 ]; scanf ( ...
No comments:
Post a Comment