C + + program to find a node

Posted by Didi Setyapramana On 1:27 AM 0 komentar

# Include <cstdlib> 
# Include <iostream> 
using namespace std; 
int main (int argc, char * argv []) { 
    char g [10]; 
    int j [10]; 
    int a, b, c; 
    int d = 0; 
    
    cout <<"Enter the Number of Nodes:"; 
    cin>> a; 
    
    for (b = 0; b <a, b + +) 
    { 
         cout <<"Node Name [" <<b +1 <<"]:"; 
         cin>> g [b]; 
    } 
    for (c = 0; c <a, c + +) 
    { 
         if (c +1 <a) 
         { 
             cout <<"Distance" <<g [c] <<"With" <<g [c +1 ]<<":"; 
             cin>> j [c]; 
         } 
         else 
         { 
             cout <<"Distance" <<g [c] <<"With" <<g [0 ]<<":"; 
             cin>> j [c]; 
         } 
    d + = j [c]; 
    } 
    
    cout <<"Total Distance:" <<d; 
    cout <<endl; 
    
    system ("PAUSE"); 
    return EXIT_SUCCESS; } 

Categories:

0 Response for the "C + + program to find a node"

Post a Comment