Last active
October 18, 2017 12:05
-
-
Save lsiddiqsunny/a2217b2d3878fbb9b090af31ca17f537 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
#define mx 505 | |
long long matrix[mx][mx]; | |
int main() | |
{ | |
memset(matrix,INT_MAX,sizeof matrix); | |
int n; | |
scanf("%d",&n); | |
for(int i=1; i<=n; i++) | |
{ | |
for(int j=1; j<=n; j++) | |
{ | |
scanf("%d",&matrix[i][j]); | |
} | |
} | |
for(int k=1; k<=n; k++) | |
{ | |
for(int i=1; i<=n; i++) | |
{ | |
for(int j=1; j<=n; j++) | |
{ | |
if ((matrix[i][k] + matrix[k][j] )< matrix[i][j]) | |
{ | |
matrix[i][j] = matrix[i][k] + matrix[k][j]; | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment