You are on page 1of 5

// Sorting_v.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#define N 20000
#define numberOfRows 2
#define numberOfCol 9

using namespace std;


string tablepp[100];

int main()
{

//***************************************************************************
********************//
int maxrows = 2, maxcolums = 4;//the variables that dont fill the collums has
to be zero
string tablep[2][9];
string f1, f2, f3, f4, f5, f6, f7, f8, f9, f10;
int positionLine = 0, positionCol = 0;
string rows[numberOfRows], collums[numberOfCol];
int finalTable[numberOfRows][numberOfRows];//all to be zero i have to
inizializw that
fstream finalFile;
finalFile.open("asasasas.txt");
int poss = 0;

if (finalFile.is_open())
{

while (!finalFile.eof())
{
getline(finalFile, f1, ',');
cout << "f1 is : " << f1 << '\n';
getline(finalFile, f2, ',');
cout << "f2 is : " << f2 << '\n';
getline(finalFile, f3, ',');
cout << "f3 is : " << f3 << '\n';
getline(finalFile, f4, ',');
cout << "f4 is : " << f4 << '\n';
getline(finalFile, f5, ',');
cout << "f5 is : " << f5 << '\n';
getline(finalFile, f6, ',');
cout << "f6 is : " << f6 << '\n';
getline(finalFile, f7, ',');
cout << "f7 is : " << f7 << '\n';
getline(finalFile, f8, ',');
cout << "f8 is : " << f8 << '\n';
getline(finalFile, f9, ',');
cout << "f9 is : " << f9 << '\n';
getline(finalFile, f10, '\n');
//cout << "f11 is : " << f10 << '\n';
tablep[poss][0] = f2;
tablep[poss][1] = f3;
tablep[poss][2] = f4;
tablep[poss][3] = f5;
tablep[poss][4] = f6;
tablep[poss][5] = f7;
tablep[poss][6] = f8;
tablep[poss][7] = f9;
tablep[poss][8] = f10;
poss++;
}
}
else
{
cout << "cant open file";
}

cout << "before " << tablep[0][1] << endl;


/*for (int i = 0; i < numberOfRows; i++) {
for (int j = 0; j < numberOfCol; j++) {
cout << tablep[i][j] << '\t';
}
cout << '\n';
}*/
//create a tabke without doubles names tablep
int uuu = 0;
int found = 1;

//cout << tablep[1][1] << '\t' << tablep[1][2] << endl;


for (int u = 0; u < numberOfRows; u++) {
for (int uu = 0; uu < numberOfCol; uu++)
{
if (u == 0 && uu == 0)
{
tablepp[uuu] = tablep[u][uu];
uuu++;
//cout << "first on the list" << '\t' << tablep[u][uu]
<<'\n';
}
else
{
for (int j = 0; j < uuu; j++) {

if (tablepp[j].compare(tablep[u][uu]) == 0) {
// cout <<
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" << '\n';
found = 0;
}

}
if (found == 1) {
if (atoi(tablep[u][uu].c_str()) != 0) {
tablepp[uuu] = tablep[u][uu];
uuu++;
}

}
found = 1;
}
}

}
for (int l = 0; l < 100; l++) {
if (atoi(tablepp[l].c_str()) != 0) {
cout << tablepp[l] << endl;
}
}
cout << "before " << tablep[0][1] << endl;
//***************************************************************************
***********************************************************
finalFile.close();
cout << "before " << tablep[0][1] << endl;
int positionline = 0;
int finaltable[100][100] ;
int j = 0;
/*for (int l = 0; l <100; l++) {
for (int m = 0; m < 100; m++) {
finalTable[l][m] = 0;
}

}*/

cout << "before " << tablep[0][1] << endl;


cout << tablep[0][1]<<endl;
for (int k = 0; k<numberOfRows; k++) {//for everey line do
for (int i = 0; i<9; i++)//mexri i prwti stili na einai isi me to 0
{
//cout << "table "<<tablep[k][i] << endl;
if (atoi(tablep[k][i].c_str()) != 0) {
//cout <<
"asdasddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
dddddddddddddddd";
for (int j = 0; j<100; j++)
{

if (tablep[k][i].compare(tablepp[j]) == 0)
{
if (atoi(tablepp[j].c_str()) != 0) {
positionline = j;
}

}
for (int l = 0; l<9; l++)
{
if (l != j)
{
for (int a = 0; a<numberOfCol; a++)
{
for (int aa = 0; aa < 100; aa++) {
if (atoi(tablep[k][a].c_str()) !=
0) {
if (tablep[k]
[a].compare(tablepp[aa]) == 0)
{
finaltable[j][aa] =
finaltable[j][aa] + 1;

break;
}
}
}

}
}
}
}
}

}
for (int l = 0; l <8; l++) {
for (int m = 0; m < 8; m++) {
cout << finalTable[l][m] << '\t';
}
cout << endl;
}

//*********************************************************************************
***************//

//cout << count;


system("pause");
return 0;

int search(int number) {


int position = 0;
for (int i = 0; i < 100; i++)
{
if (atoi(tablepp[i].c_str()) != 0) {

if (number == atoi(tablepp[i].c_str()) == 0) {
position = i;
}

}
}
return position;
}

You might also like