Facebook
From Agacia, 5 Years ago, written in C++.
This paste is a reply to akwb - odczyt from Agacia - go back
Embed
Viewing differences between akwb - odczyt and Re: akwb - odczyt
// AKwBZ1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include  
#include 
#include 
#include 
#include 

using namespace std;

int GRAPH[20][20] = {};
int TOTV;
void printGraph(int V)
{
        cout << "   ";
        for (int b = 0; b < V; b++)
                cout << b + 1 << " ";
        cout << endl;
        for (int i = 0; i         {
                cout << i + 1 << "| ";
                for (int j = 0; j                 {
                        
                        cout << GRAPH[i][j] << " ";
                }
                cout << endl;
        }
}

void load()
{
        ifstream in;
        int inV, outV;
        int i = 0;
        string line;
                in.open("data.txt");
                if (in.is_open())
                {
                        getline(in, line);
                        TOTV = stoi(line);
                        
                        while (in.good())
                        { 
                                getline(in, line);
                                stringstream ssin(line);
                                while (ssin.good()) {
                                        ssin >> outV;
                                        ssin >> inV;
                                        GRAPH[outV-1][inV-1]++;
                                }
                        }
                }
                else
                {
                        cout << "Error loading";
                }
}

int main()
{
        string cmd;
        load();
        printGraph(TOTV);
        while (1) 
        {
                cout << "Input command: ";
                cin >> cmd;
                if (cmd == "exit" || cmd=="e")
                        return 0;
                else if (cmd == "print")
                        printGraph(TOTV);
        }
    return 0;
}

Replies to Re: akwb - odczyt rss

Title Name Language When
Re: Re: akwb - odczyt Agacia cpp 5 Years ago.