Advertisement
Aminpro

[ECP1026]Tutorial 6

Dec 12th, 2012
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. http://facebook.com/aminpropastebin
  2. #include <stdio.h>
  3. #include <string.h>
  4. #define numplace 3
  5. #define nop -1
  6.  
  7. int main(){
  8.  
  9. char places[numplace]={"Adam","Sofea","Raja"};
  10. int roads[numplace][numplace] = {{0,nop,2},{3,0,nop},{nop,5,0}};
  11. int from, to;
  12. char buff[10];
  13.  
  14.     printf("From: ");
  15.     fgets(buff,9,stdin);
  16.     for(from=;from<numplace;from++){
  17.         if (strstr(places[from], buff))break;
  18.         }
  19.     printf("To: ");
  20.     fgets(buff,9,stdin);
  21.     for(to=0;to<numplace;to++){
  22.         if (strstr(places[to],buff))break;
  23.         }
  24.     printf("From %s to %s: ", places[from], places[to])'
  25.     if(roads[from][to] != nop){
  26.         printf("It is %d KM", roads[from][to]);
  27.         }
  28.     else
  29.         printf("There is no direct path);
  30.  
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement