Alter Code? Wie bringe ichs zum Laufen?



  • Hallo Freunde,

    ich weiß nicht, ob ich hier richtig bin aber irgendwo muss ich meine Anfrege loswerden. Ich habe einen C++Code bekommen, der mir einige Kennzahlen berechnen soll. Ich weiß inzwischen, dass er uralt ist und mit aktuellen Compilern nicht zum Laufen zu bringen ist (iostream.h und so..). Selbst aktualisieren kann ich ihn nicht: Ich habe keine Ahnung vom Programmieren. Kann vielleicht einer von Euch Experten mir sagen, was ich anpassen muss, damit die Sache rund läuft? Ich habe inzwischen sogar Visual C++ 5.0 (von 1997!) installiert aber auch dann bekomme ich nur Errors. Schon jetzt meine tiefste Verneigung für Euroe hilfreichen Tipps!

    Hier ist der Code. Dazu gibt es noch eine Datei, aus der er die Zahlen entnehmen soll.

    //program for checking complexity data for redundant trait numbers
    #include <iostream.h>
    #include <fstream.h>
    #include <iomanip.h>
    #include <math.h>
    #include <stdlib.h>

    //NOTE: THE NUMBER OF SUBJECTS SHOULD FIT THE SPECIFIC RUNNING OF THE PROGRAM
    #define SUBJECTS 60
    #define ASPECTS 20
    #define TRAITS 44

    int main()
    {

    int naspect, temp;
    double subject, age, sex, year_school;

    //creating output file and checking it
    ofstream outfile ("errors.txt", ios::out);
    if (!outfile) {
    cerr << "Out file couldn't be opened" << endl;
    exit (1);
    }

    //creating intput file and checking it
    ifstream infile ("complex.prn", ios::in);
    if (!infile) {
    cerr << "In file couldn't be opened" << endl;
    exit (2);
    }
    int ratings[ASPECTS][TRAITS];

    for (int entries = 0; entries<SUBJECTS; entries++)
    {
    infile >> subject >> naspect >> age >> sex >> year_school;

    for (int k=0; k<ASPECTS; k++)
    {
    for (int l=0; l<TRAITS;l++)
    ratings[k][l]=0;
    }

    for (int j=0; j < naspect ; j++)
    {
    infile >> temp;
    while (temp != 0)
    {
    ratings[j][temp-1]++;
    if (ratings[j][temp-1] > 1)
    outfile << subject << ", " << j << ", " << temp << endl;
    infile >> temp;
    }
    }

    }
    return (0);
    }



  • Jetzt komm, die paar Zeilen wirst doch wohl selber anpassen oder in paar Minuten neuschreiben können?



  • Auf den ersten Blick könnte es reichen

    #include <iostream.h>
    #include <fstream.h>
    #include <iomanip.h>
    #include <math.h>
    #include <stdlib.h>
    

    mit

    #include <iostream>
    #include <fstream>
    #include <iomanip>
    #include <math.h>
    #include <stdlib.h>
    using namespace std;
    

    zu ersetzen.



  • ja genau. das habe ich geändert und der compiler ist schon ein gutes stück weiter gekommen. vielleicht können wir uns so bis zur lösung durchtasten.

    jetzt habe ich folgende fehlermeldungen. (meldungen ähnlichen typs wiederholen sich danach. vielleicht können wir diese hier klären, sodass ich hoffentlich den rest irgendwie hinkriege).

    1>------ Erstellen gestartet: Projekt: four, Konfiguration: Debug Win32 ------
    1>Kompilieren...
    1>COMPARE.CPP
    1>c:\users\cranberry\desktop\rafaelis\compare.cpp(127) : error C2065: 'i': nichtdeklarierter Bezeichner
    1>c:\users\cranberry\desktop\rafaelis\compare.cpp(155) : error C2668: 'log': Mehrdeutiger Aufruf einer überladenen Funktion
    1>        c:\program files\microsoft visual studio 8\vc\include\math.h(567): kann 'long double log(long double)' sein
    1>        c:\program files\microsoft visual studio 8\vc\include\math.h(519): oder "float log(float)"
    1>        c:\program files\microsoft visual studio 8\vc\include\math.h(121): oder "double log(double)"
    


  • Welches ist denn Zeile 127? Ich seh nirgendwo ein i...



  • Ok, jetzt sieht mans besser.

    [code=

    //program for computing and comparing overlap measures,
    //which writes a file with the necessary statistics
    
    #include <iostream>
    #include <fstream>
    #include <iomanip>
    #include <math.h>
    #include <stdlib.h>
    using namespace std;
    
    //NOTE: THE NUMBER OF SUBJECTS SHOULD FIT THE SPECIFIC RUNNING OF THE PROGRAM
    #define SUBJECTS 169
    #define ASPECTS 20
    #define TRAITS 44
    
    double linville(int [][TRAITS], int); //prototype for the linville SC function
    int negdiverse(int [][TRAITS], int); //prototype for role valence function
    int posdiverse(int [][TRAITS], int); //prototype for role valence function
    double overlap(int [][TRAITS], int, double &, double &); //prototype for pair-wise overlap function
    int usage(int [][TRAITS], int, int &, int &,	int &, int &, int &);
    												//prototype for trait overlap function
    
    int main()
    {
    
    	int naspect, temp, stam;
    	double subject;
    
    	//creating output file and checking it
    	ofstream outfile ("gleaned.txt", ios::out);
    	if (!outfile) {
    		cerr << "Out file couldn't be opened" << endl;
    		exit (1);
    	}
    
    	//creating intput file and checking it
    	ifstream infile ("complex.prn", ios::in);
    	if (!infile) {
    		cerr << "In file couldn't be opened" << endl;
    		exit (2);
    	}
    
    	int ratings[ASPECTS][TRAITS];
    
    	for (int entries = 0; entries<SUBJECTS; entries++)
    	{
    		infile >> subject >> naspect;
    
    		for (int k=0; k<ASPECTS; k++)
    			for (int l=0; l<TRAITS;l++)
    				ratings[k][l]=0;
    
    		for (int j=0; j < naspect ; j++)
    		{
    			infile >> temp;
    			while (temp != 0)
    			{
    				ratings[j][temp-1]++;
    				infile >> temp;
    			}
    		}
    
    		//computing the neccesary statistics
    
    		double linvSC=linville(ratings, naspect);
    		int posroles = posdiverse(ratings, naspect);
    		int negroles = negdiverse(ratings, naspect);
    		double pairOL2 =0.0, pairOL3 =0.0;
    		double pairOL = overlap(ratings, naspect, pairOL2, pairOL3);
    		int used=0, pos_used =0, neg_used=0, pos_reused=0, neg_reused=0;
    		int reused=usage(ratings, naspect, used, pos_used, neg_used,
    								pos_reused, neg_reused);
    
    		//printing to file the subject #, nroles, and the subjects array
    
    		outfile << subject << ", " << naspect << ", " << linvSC << ", ";
    //		outfile << posroles << ", " << negroles << ", ";
    //		outfile << used << ", " << pos_used << ", " << neg_used << ", ";
    //		outfile << reused << ", " << pos_reused << ", " << neg_reused << ", ";
    		outfile << pairOL << ", " << pairOL2 << ", " << pairOL3 << endl;
    
    //		for (int i=0; i < naspect ; i++)
    //		{
    //			for (int j=0; j < 44 ; j++){
    //				outfile << ratings[i][j] << ",";
    //			}
    //		outfile << endl;
    //		}
    	stam=entries;
    	}
    	return (0);
    }
    
    //function for computing Linville's SC
    double linville(int arr[][TRAITS], int roles)
    {
    	int diff;
    	int gc[TRAITS] = {0};  //group combination
    	int ugc[TRAITS] = {0}; //unique group combination
    
    	//NOTE: the values of the gc[] array are 1-nugc, not 0-nugc
    
    	int counter=0;
    	for (int i=0;i<TRAITS-1;i++)	 					//one pass of "criterion"
    	{
    		if (gc[i]==0) {counter++; gc[i]=counter;} //assigning a new gc if need
    
    		for (int j=i+1; j<TRAITS; j++)				//one pass of the compared
    		{
    			diff = 0;
    			for (int k=0; k<roles; k++)			//a pass of all the ratings
    				diff += abs(arr[k][i]-arr[k][j]);   //of the two traits across
    			if ((diff ==0) && (gc[j]==0)) gc[j]=gc[i];   //all aspects.
    		}
    	}
    
    	int hold=0; //sorting the gc (group combination array)
    	for (int pass=0; pass<TRAITS; pass++)
    		for (i=0;i<TRAITS-1;i++)
    			if (gc[i]<gc[i+1])
    			{
    				hold=gc[i];
    				gc[i]=gc[i+1];
    				gc[i+1]=hold;
    			}
    
    	int nugc=gc[0]; //the number of unique gc's is necessarily equal to the
    					//gc that is now in gc[0]
    
    	int gopher=nugc;
    	counter=0;
    	for (i=0; i<TRAITS; i++) //going thru the sorted gc array and forming
    	{								 //the ugc array, in however many of the ASPECTS
    		if (gopher==gc[i])    //cells that are neccesary.
    			ugc[counter]++;
    		else {
    			gopher--;
    			counter++;
    			ugc[counter]++;
    		}
    	}
    
    	double attneave = 0.0, sigma = 0.0;
    	for (i=0; i<nugc; i++)
    		sigma+=ugc[i]*(log(ugc[i])/log(2));
    	attneave = log(TRAITS)/log(2) - sigma/TRAITS;
    	return (attneave);
    }
    
    //function to count predominantly negative roles
    int negdiverse(int arr[][TRAITS], int roles)
    {
    	int role_valence, sub_valence = 0, j, k;
    	for (k=0; k<roles; k++)
    	{
    		role_valence = 0;
    		for (j=0 ; j<TRAITS ; j++)
    		{
    			if (arr[k][j]>0)
    			{
    				if ((j==0)||(j==3)||(j==4)||(j==7)||(j==10)||(j==13)||
    				(j==15)||(j==17)||(j==19)||(j==20)||(j==22)||(j==24)||
    				(j==25)||(j==26)||(j==29)||(j==31)||(j==32)||(j==34)||
    				(j==37)||(j==40)||(j==41))
    					role_valence=role_valence++;
    				else role_valence=role_valence--;
    			}
    		}
    		if (role_valence>0) sub_valence++;
    	}
    	return (sub_valence);
    }
    
    //function to count predominantly positive roles
    int posdiverse(int arr[][TRAITS], int roles)
    {
    	int role_valence, sub_valence = 0, j, k;
    	for (k=0; k<roles; k++)
    	{
    		role_valence = 0;
    		for (j=0 ; j<TRAITS ; j++)
    		{
    			if (arr[k][j]>0)
    			{
    				if ((j==0)||(j==3)||(j==4)||(j==7)||(j==10)||(j==13)||
    				(j==15)||(j==17)||(j==19)||(j==20)||(j==22)||(j==24)||
    				(j==25)||(j==26)||(j==29)||(j==31)||(j==32)||(j==34)||
    				(j==37)||(j==40)||(j==41))
    					role_valence=role_valence++;
    				else role_valence=role_valence--;
    			}
    		}
    		if (role_valence<0) sub_valence++;
    	}
    	return (sub_valence);
    }
    
    double overlap(int arr[][TRAITS], int roles, double &pairOL2, double &pairOL3)
    //prototype for pair-wise overlap function,
    //computing three different possibilities for overlap.
    //pairOL = mean of (common/total1*common/total2)
    //pairOL2 = mean of (common-(unique1+unique2))
    //pairOL3= mean of (common/total1+common/total2)
    {
    	int common=0, first=0, second=0, ufirst=0, usecond=0;
    	double pairwise=0.0, pw2=0.0, pw3=0.0;
    
    	for (int m=0; m<roles-1; m++)
    		for (int n=m+1; n<roles; n++)
    		{
    			for (int i=0; i<TRAITS; i++)
    			{
    				if (arr[m][i]==1)
    				{
    					if (arr[n][i]==1)
    					{
    						common+=1;
    						first+=1;
    						second+=1;
    					}
    					else
    					{
    						first+=1;
    						ufirst+=1;
    					}
    				}
    				else
    				{
    					if (arr[n][i]==1)
    					{
    						second+=1;
    						usecond+=1;
    					}
    				}
    			}
    			pairwise+= ((double(common)*common)/(first*second));
    			pw2 += common - (ufirst + usecond);
    			pw3 += (double(common)/first) + (double(common)/second);
    			common = first = second = ufirst = usecond = 0;
    		}
    	pairOL2=pw2/(roles*(roles-1)/2);
    	pairOL3=pw3/(roles*(roles-1));
    	return (pairwise/(roles*(roles-1)/2));
    }
    
    int usage(int arr[][TRAITS], int roles, int &used, int &pos_used,
    				int &neg_used, int &pos_reused, int &neg_reused)
    {
    	int reused=0, temp[TRAITS] = {0};
    
    	for (int j=0 ; j<TRAITS; j++)
    		for (int k=0; k<roles; k++)
    		{
    			used+=arr[k][j];
    			temp[j]+=arr[k][j];
    			if (arr[k][j]>0)
    			{
    				if ((j==0)||(j==3)||(j==4)||(j==7)||(j==10)||(j==13)||
    				(j==15)||(j==17)||(j==19)||(j==20)||(j==22)||(j==24)||
    				(j==25)||(j==26)||(j==29)||(j==31)||(j==32)||(j==34)||
    				(j==37)||(j==40)||(j==41))
    					neg_used++;
    				else pos_used++;
    			}
    		}
    	for (j=0; j<TRAITS; j++)
    		if (temp[j]>1)
    		{
    			reused+=(temp[j]-1);
    			if ((j==0)||(j==3)||(j==4)||(j==7)||(j==10)||(j==13)||
    			(j==15)||(j==17)||(j==19)||(j==20)||(j==22)||(j==24)||
    			(j==25)||(j==26)||(j==29)||(j==31)||(j==32)||(j==34)||
    			(j==37)||(j==40)||(j==41))
    				neg_reused+=(temp[j]-1);
    			else pos_reused+=(temp[j]-1);
    		}
    	return (reused);
    }
    

    "cpp"]



  • Das ist jetzt aber mehr Code als oben ^^

    Mach mal aus:

    for (i=0;i<TRAITS-1;i++)
    

    das:

    for (int i=0;i<TRAITS-1;i++)
    


  • ja, tatsächlich. ist mehr code. und es ist sogar ein anderer. aber das problem ist das gleich. bleiben wir also bei dem zuletzt geposteten 😉

    ich habe deinen vorschlag ins programm eingebracht und noch an einigen stellen widerholt. danke.

    jetzt habe ich sowas hier vorliegen:

    1>------ Erstellen gestartet: Projekt: four, Konfiguration: Debug Win32 ------
    1>Kompilieren...
    1>COMPARE.CPP
    1>c:\users\cranberry\desktop\rafaelis\compare.cpp(155) : error C2668: 'log': Mehrdeutiger Aufruf einer überladenen Funktion
    1>        c:\program files\microsoft visual studio 8\vc\include\math.h(567): kann 'long double log(long double)' sein
    1>        c:\program files\microsoft visual studio 8\vc\include\math.h(519): oder "float log(float)"
    1>        c:\program files\microsoft visual studio 8\vc\include\math.h(121): oder "double log(double)"
    


  • schreib mal

    log( static_cast<double> ( x ) )  // statt log(x)
    

    Btw. 😃

    role_valence=role_valence++; 
    else
        role_valence=role_valence--;
    


  • Wieso will jemand der keine Ahnung von Programmierung hat, Code zum laufen bringen?



  • weil es dieses programm hier nur in dieser form gibt. und ich muss es irgendwie ausführen können.
    mit euren beiträgen leistet ihr einen aktiven beitrag gegen meine c++-ahnungslosigkeit! wenn das hier vorbei ist, nehme ich mir vor auf systematischere art und weise etwas über c++ (und programmieren allgemein) zu lernen.



  • Ok, der Compiler scheint den Code (mit Euren vorgeschlagenen Änderungen) jetzt gefressen zu haben: es läuft durch und es erscheint zum Schluss ein schwarzes Eingabefenster mit einem blinkenden Unterstrich. Jetzt wird es für mich aber komplett undurchsichtlich. Was er mir in die Output-Datei reinschreibt ist nur eine Zeile. In der Input-Datei(complex.prn) sind aber 59 Datensätze. Ich vermute mal ganz naiv, dass auch ungefähr so viele Zeilen Output rauskommen sollten.

    Findet vielleicht einer von Euch den Fehler?

    Es ist davon auszugehen, dass das Programm vor vielen Jahren schon mal funktinierte.

    Ich kopiere mal den aktuellen Code noch in

    //program for computing and comparing overlap measures,
    //which writes a file with the necessary statistics
    
    #include <iostream>
    #include <fstream>
    #include <iomanip>
    #include <math.h>
    #include <stdlib.h>
    using namespace std;
    
    //NOTE: THE NUMBER OF SUBJECTS SHOULD FIT THE SPECIFIC RUNNING OF THE PROGRAM
    #define SUBJECTS 60
    #define ASPECTS 20
    #define TRAITS 44
    
    double linville(int [][TRAITS], int); //prototype for the linville SC function
    int negdiverse(int [][TRAITS], int); //prototype for role valence function
    int posdiverse(int [][TRAITS], int); //prototype for role valence function
    double overlap(int [][TRAITS], int, double &, double &); //prototype for pair-wise overlap function
    int usage(int [][TRAITS], int, int &, int &,	int &, int &, int &);
    												//prototype for trait overlap function
    
    int main()
    {
    
    	int naspect, temp, stam;
    	double subject;
    
    	//creating output file and checking it
    	ofstream outfile ("gleaned.txt", ios::out);
    	if (!outfile) {
    		cerr << "Out file couldn't be opened" << endl;
    		exit (1);
    	}
    
    	//creating intput file and checking it
    	ifstream infile ("complex.prn", ios::in);
    	if (!infile) {
    		cerr << "In file couldn't be opened" << endl;
    		exit (2);
    	}
    
    	int ratings[ASPECTS][TRAITS];
    
    	for (int entries = 0; entries<SUBJECTS; entries++)
    	{
    		infile >> subject >> naspect;
    
    		for (int k=0; k<ASPECTS; k++)
    			for (int l=0; l<TRAITS;l++)
    				ratings[k][l]=0;
    
    		for (int j=0; j < naspect ; j++)
    		{
    			infile >> temp;
    			while (temp != 0)
    			{
    				ratings[j][temp-1]++;
    				infile >> temp;
    			}
    		}
    
    		//computing the neccesary statistics
    
    		double linvSC=linville(ratings, naspect);
    		int posroles = posdiverse(ratings, naspect);
    		int negroles = negdiverse(ratings, naspect);
    		double pairOL2 =0.0, pairOL3 =0.0;
    		double pairOL = overlap(ratings, naspect, pairOL2, pairOL3);
    		int used=0, pos_used =0, neg_used=0, pos_reused=0, neg_reused=0;
    		int reused=usage(ratings, naspect, used, pos_used, neg_used,
    								pos_reused, neg_reused);
    
    		//printing to file the subject #, nroles, and the subjects array
    
    		outfile << subject << ", " << naspect << ", " << linvSC << ", ";
    //		outfile << posroles << ", " << negroles << ", ";
    //		outfile << used << ", " << pos_used << ", " << neg_used << ", ";
    //		outfile << reused << ", " << pos_reused << ", " << neg_reused << ", ";
    		outfile << pairOL << ", " << pairOL2 << ", " << pairOL3 << endl;
    
    //		for (int i=0; i < naspect ; i++)
    //		{
    //			for (int j=0; j < 44 ; j++){
    //				outfile << ratings[i][j] << ",";
    //			}
    //		outfile << endl;
    //		}
    	stam=entries;
    	}
    	return (0);
    }
    
    //function for computing Linville's SC
    double linville(int arr[][TRAITS], int roles)
    {
    	int diff;
    	int gc[TRAITS] = {0};  //group combination
    	int ugc[TRAITS] = {0}; //unique group combination
    
    	//NOTE: the values of the gc[] array are 1-nugc, not 0-nugc
    
    	int counter=0;
    	for (int i=0;i<TRAITS-1;i++)	 					//one pass of "criterion"
    	{
    		if (gc[i]==0) {counter++; gc[i]=counter;} //assigning a new gc if need
    
    		for (int j=i+1; j<TRAITS; j++)				//one pass of the compared
    		{
    			diff = 0;
    			for (int k=0; k<roles; k++)			//a pass of all the ratings
    				diff += abs(arr[k][i]-arr[k][j]);   //of the two traits across
    			if ((diff ==0) && (gc[j]==0)) gc[j]=gc[i];   //all aspects.
    		}
    	}
    
    	int hold=0; //sorting the gc (group combination array)
    	for (int pass=0; pass<TRAITS; pass++)
    		for (int i=0;i<TRAITS-1;i++)  
    			if (gc[i]<gc[i+1])
    			{
    				hold=gc[i];
    				gc[i]=gc[i+1];
    				gc[i+1]=hold;
    			}
    
    	int nugc=gc[0]; //the number of unique gc's is necessarily equal to the
    					//gc that is now in gc[0]
    
    	int gopher=nugc;
    	counter=0;
    	for (int i=0; i<TRAITS; i++) //going thru the sorted gc array and forming
    	{								 //the ugc array, in however many of the ASPECTS
    		if (gopher==gc[i])    //cells that are neccesary.
    			ugc[counter]++;
    		else {
    			gopher--;
    			counter++;
    			ugc[counter]++;
    		}
    	}
    
    	double attneave = 0.0, sigma = 0.0;
    	for (int i=0; i<nugc; i++)
    		sigma+=ugc[i]*(log (static_cast<double> (ugc[i])/log (static_cast<double> (2))));              
    	attneave = log(static_cast<double>(TRAITS)/log(static_cast<double>(2) - sigma/TRAITS));
    	return (attneave);
    }
    
    //function to count predominantly negative roles
    int negdiverse(int arr[][TRAITS], int roles)
    {
    	int role_valence, sub_valence = 0, j, k;
    	for (k=0; k<roles; k++)
    	{
    		role_valence = 0;
    		for (j=0 ; j<TRAITS ; j++)
    		{
    			if (arr[k][j]>0)
    			{
    				if ((j==0)||(j==3)||(j==4)||(j==7)||(j==10)||(j==13)||
    				(j==15)||(j==17)||(j==19)||(j==20)||(j==22)||(j==24)||
    				(j==25)||(j==26)||(j==29)||(j==31)||(j==32)||(j==34)||
    				(j==37)||(j==40)||(j==41))
    					role_valence=role_valence++;
    				else role_valence=role_valence--;
    			}
    		}
    		if (role_valence>0) sub_valence++;
    	}
    	return (sub_valence);
    }
    
    //function to count predominantly positive roles
    int posdiverse(int arr[][TRAITS], int roles)
    {
    	int role_valence, sub_valence = 0, j, k;
    	for (k=0; k<roles; k++)
    	{
    		role_valence = 0;
    		for (j=0 ; j<TRAITS ; j++)
    		{
    			if (arr[k][j]>0)
    			{
    				if ((j==0)||(j==3)||(j==4)||(j==7)||(j==10)||(j==13)||
    				(j==15)||(j==17)||(j==19)||(j==20)||(j==22)||(j==24)||
    				(j==25)||(j==26)||(j==29)||(j==31)||(j==32)||(j==34)||
    				(j==37)||(j==40)||(j==41))
    					role_valence=role_valence++;
    				else role_valence=role_valence--;
    			}
    		}
    		if (role_valence<0) sub_valence++;
    	}
    	return (sub_valence);
    }
    
    double overlap(int arr[][TRAITS], int roles, double &pairOL2, double &pairOL3)
    //prototype for pair-wise overlap function,
    //computing three different possibilities for overlap.
    //pairOL = mean of (common/total1*common/total2)
    //pairOL2 = mean of (common-(unique1+unique2))
    //pairOL3= mean of (common/total1+common/total2)
    {
    	int common=0, first=0, second=0, ufirst=0, usecond=0;
    	double pairwise=0.0, pw2=0.0, pw3=0.0;
    
    	for (int m=0; m<roles-1; m++)
    		for (int n=m+1; n<roles; n++)
    		{
    			for (int i=0; i<TRAITS; i++)
    			{
    				if (arr[m][i]==1)
    				{
    					if (arr[n][i]==1)
    					{
    						common+=1;
    						first+=1;
    						second+=1;
    					}
    					else
    					{
    						first+=1;
    						ufirst+=1;
    					}
    				}
    				else
    				{
    					if (arr[n][i]==1)
    					{
    						second+=1;
    						usecond+=1;
    					}
    				}
    			}
    			pairwise+= ((double(common)*common)/(first*second));
    			pw2 += common - (ufirst + usecond);
    			pw3 += (double(common)/first) + (double(common)/second);
    			common = first = second = ufirst = usecond = 0;
    		}
    	pairOL2=pw2/(roles*(roles-1)/2);
    	pairOL3=pw3/(roles*(roles-1));
    	return (pairwise/(roles*(roles-1)/2));
    }
    
    int usage(int arr[][TRAITS], int roles, int &used, int &pos_used,
    				int &neg_used, int &pos_reused, int &neg_reused)
    {
    	int reused=0, temp[TRAITS] = {0};
    
    	for (int j=0 ; j<TRAITS; j++)
    		for (int k=0; k<roles; k++)
    		{
    			used+=arr[k][j];
    			temp[j]+=arr[k][j];
    			if (arr[k][j]>0)
    			{
    				if ((j==0)||(j==3)||(j==4)||(j==7)||(j==10)||(j==13)||
    				(j==15)||(j==17)||(j==19)||(j==20)||(j==22)||(j==24)||
    				(j==25)||(j==26)||(j==29)||(j==31)||(j==32)||(j==34)||
    				(j==37)||(j==40)||(j==41))
    					neg_used++;
    				else pos_used++;
    			}
    		}
    	for (int j=0; j<TRAITS; j++) 
    		if (temp[j]>1)
    		{
    			reused+=(temp[j]-1);
    			if ((j==0)||(j==3)||(j==4)||(j==7)||(j==10)||(j==13)||
    			(j==15)||(j==17)||(j==19)||(j==20)||(j==22)||(j==24)||
    			(j==25)||(j==26)||(j==29)||(j==31)||(j==32)||(j==34)||
    			(j==37)||(j==40)||(j==41))
    				neg_reused+=(temp[j]-1);
    			else pos_reused+=(temp[j]-1);
    		}
    	return (reused);
    }
    

    Unten steht da noch sowas:

    "six.exe": "C:\Users\Cranberry\Desktop\Rafaelis\six\Debug\six.exe" geladen, Symbole wurden geladen.
    "six.exe": "C:\Windows\System32\ntdll.dll" geladen, Keine Symbole geladen.
    "six.exe": "C:\Windows\System32\kernel32.dll" geladen, Keine Symbole geladen.
    "six.exe": "C:\Windows\winsxs\x86_microsoft.vc80.debugcrt_1fc8b3b9a1e18e3b_8.0.50727.42_none_ef74ff32550b5bf0\msvcp80d.dll" geladen, Keine Symbole geladen.
    "six.exe": "C:\Windows\winsxs\x86_microsoft.vc80.debugcrt_1fc8b3b9a1e18e3b_8.0.50727.42_none_ef74ff32550b5bf0\msvcr80d.dll" geladen, Keine Symbole geladen.
    "six.exe": "C:\Windows\System32\msvcrt.dll" geladen, Keine Symbole geladen.
    Der Thread 'Win32 Thread' (0xc2dc) hat mit Code -1073741510 (0xc000013a) geendet.
    Das Programm "[50604] six.exe: Systemeigen" wurde mit Code -1073741510 (0xc000013a) beendet.
    


  • Der Exit-Code bedeutet, dass du das Programm mit Ctrl+C abgebrochen hast. Einfach mal laufen lassen (das "schwarze Fenster" erscheint auch nicht zum Schluss, sondern am Anfang, gleich nachdem der Compiler und Linker fertig sind). Bei Zweifeln wird es Zeit, sich mit den Möglichkeiten des Debuggings auseinanderzusetzen...



  • Self-Structure schrieb:

    Was er mir in die Output-Datei reinschreibt ist nur eine Zeile. In der Input-Datei(complex.prn) sind aber 59 Datensätze. Ich vermute mal ganz naiv, dass auch ungefähr so viele Zeilen Output rauskommen sollten.

    Ohne den Inhalt dieser Datei (complex.prn) zu kennen, können wir nicht sagen, wieviele Zeilen es schreiben sollte.
    (Sonst füg halt etwas mehr Ausgaben ein, dann siehst du ja, was er wann und wie oft macht.)


Anmelden zum Antworten