fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. #define INF 9999
  5. {
  6. int arr[4][4] ;
  7. int cost[4][4] = {
  8. 7, 5, 0, 0,
  9. 7, 0, 0, 2,
  10. 0, 3, 0, 0,
  11. 4, 0, 1, 0
  12. } ;
  13. int i, j, k, n = 4 ;
  14.  
  15. clrscr( ) ;
  16.  
  17. for ( i = 0 ; i < n ; i++ )
  18. {
  19. for ( j = 0; j < n ; j++ )
  20. {
  21. if ( cost[i][j] == 0 )
  22. arr[i][j] = INF ;
  23. else
  24. arr[i][j] = cost[i][j] ;
  25. }
  26. }
  27.  
  28. printf ( "Adjacency matrix of cost of edges:\n" ) ;
  29. for ( i = 0 ; i < n ; i++ )
  30. {
  31. for ( j = 0; j < n ; j++ )
  32. printf ( "%d\t", arr[i][j] ) ;
  33. printf ( "\n" ) ;
  34. }
  35.  
  36. for ( k = 0 ; k < n ; k++ )
  37. {
  38. for ( i = 0 ; i < n ; i++ )
  39. {
  40. for ( j = 0 ; j < n ; j++ )
  41. {
  42. if ( arr[i][j] > arr[i][k] + arr[k][j] )
  43. arr[i][j] = arr[i][k] + arr[k][j];
  44. }
  45. }
  46. } printf ( "\nAdjacency matrix of lowest cost between the vertices:\n" ) ;
  47. for ( i = 0 ; i < n ; i++ )
  48. {
  49. for ( j = 0; j < n ; j++ )
  50. printf ( "%d\t", arr[i][j] ) ;
  51. printf ( "\n" ) ;
  52. }
  53.  
  54. getch( ) ;
  55. }
  56.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:7:22: warning: missing braces around initializer [-Wmissing-braces]
     int cost[4][4] = {
                      ^
prog.c:7:22: note: (near initialization for ‘cost’)
prog.c:15:5: warning: implicit declaration of function ‘clrscr’ [-Wimplicit-function-declaration]
     clrscr( ) ;
     ^~~~~~
prog.c:54:5: warning: implicit declaration of function ‘getch’ [-Wimplicit-function-declaration]
     getch( ) ;
     ^~~~~
/home/trjvrH/cchVk7gi.o: In function `main':
prog.c:(.text.startup+0x97): undefined reference to `clrscr'
prog.c:(.text.startup+0x1b9): undefined reference to `getch'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty