Thread: one function in my program won't work....

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    69

    one function in my program won't work....

    This project is a continuation of an old project my class did. the only difference is in the input, where they may enter up to 30 numbers instead of 6. This intersection function worked in the last program, but when I try to call it in this program, it just ends the program. It doesn't even make it through the function before quitting the program.

    Here's the function code for intersection:

    p.s.- the i array is a globally defined int variable above my main function

    Code:
    void intersection()
    {
    	int number=0;
    	int count=0;
    	int intersect=0;
    	do
    	{
    		i[count]=99999;
    		count++;
    	}
    	while (count<=30);
    	count=0;
    	do
    	{
    		do
    		{
    			if (array_a[number]==array_b[count])
    			{
    				i[intersect]=array_a[number];
    				intersect++;
    			}
    			number++;
    
    		}
    		while (number<30);
    		number=0;
    		count++;
    	}
    	while (count<30);
    
    	number=0;
    	count=1;	
    	
    	do
    	{
    		do
    		{
    			if ((i[number]==i[count])&&(number!=count))
    			{
    				i[count]=99999;
    				count++;
    			}
    			else
    			{
    				count++;
    			}
    		}
    		while (count<=30);
    		number++;
    		count=0;
    	}
    	while (number<30);
    	cout<<"The intersection of A and B is:" <<endl;
    	intersect=0;
    	if (i[intersect]==99999)
    	{
    		cout<<"null set" <<endl;
    	}
    	else
    	{
    		cout<<i[intersect];
    		intersect++;
    	}
    	do
    	{
    		if (i[intersect]!=99999)
    		{
    			cout<<", " <<i[intersect];
    			intersect++;
    		}
    	}
    	while (intersect<30&&i[intersect]!=99999);
    	cout<<endl;
    	system("pause");
    	cout<<endl;
    	menu();
    }
    i just ran it again, and i get an error when executing intersection:


    -------------------------------------------------------------------------------
    Debug Error!

    Program: ...Structures\c++ source files\Debug\proj2(trying to fix it).exe


    abnormal program termination

    (Press Retry to debug the application)

    -------------------------------------------------------------------------------

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Try changing your while( count <= 30 ) lines to 'count < 30'. Otherwise it will try to access array slot 30 (the 31st slot), most likely causing an access exception.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    69
    ok, i fixed those '<=' parts, but i still get the error.

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    69
    little bump right before i go to bed

  5. #5
    Registered User sikamikaniko's Avatar
    Join Date
    Mar 2003
    Posts
    28

    Just an advice

    Use "for" instead "do/while" :
    [code]
    do
    {
    i[count]=99999;
    count++;
    }
    while (count<30);
    [\code]

    like this

    [code]

    for(count=0;count<30;count++)
    {i[count]=99999;}
    [\code]

    And also there is an error code: while (count<=30); U don't need the = sign.

  6. #6
    Registered User sikamikaniko's Avatar
    Join Date
    Mar 2003
    Posts
    28
    Use "for" instead "do/while" :
    Code:
    do
    {
    i[count]=99999;
    count++;
    }
    while (count<30);
    like this

    Code:
    for(count=0;count<30;count++)
    {i[count]=99999;}
    And also there is an error code: while (count<=30); U don't need the = sign.

  7. #7
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    abnormal program termination

    (Press Retry to debug the application)
    Did you press Retry ? If so, your debugger would have given you the error we are trying to guess. Use the debugger as often as possible, it's a powerful tool
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  8. #8
    Registered User
    Join Date
    Oct 2002
    Posts
    69
    hmm, i pressed retry to debug, but it just pops up the same error again every time i press it. that's odd...

  9. #9
    Registered User
    Join Date
    Feb 2003
    Posts
    162
    I'll take a look at it for you, if you gimme the complete code....I just ran it with the main program just calling intersection, and just taking out the call to menu(), and it compiled and ran fine

  10. #10
    Registered User
    Join Date
    Mar 2003
    Posts
    73
    Originally posted by Jamsan
    I just ran it with the main program just calling intersection, and just taking out the call to menu(), and it compiled and ran fine
    Yeah, I've had the same errors in my programs when I use functions of type void. My book says it's ok to "return 0" to exit void functions, but I try that and it yells at me. Also, I get errors while trying to call function main() like you did. Simply let the function end, it will return to it's last state in the main() function by itself (or should).

    It also could depend on your compiler.

    EDIT: Oops, that said "menu()" not "main()" lol. Either way, that could be what's causing the error.

  11. #11
    Registered User
    Join Date
    Feb 2003
    Posts
    162
    Just post your code

  12. #12
    Registered User
    Join Date
    Oct 2002
    Posts
    69
    ok, here's the code. sorry for the excessive copy pasted functions at the end, but hey.

    look for the line in intersection that has a comment by it saying that this line is the one causing problems. I commented it out and the intersection function will run without crashing the program, but when I put it back in it starts crashing again.

    Code:
    #include <iostream>
    #include <cstdlib>
    using namespace std;
    
    
    void menu();
    void intersection();
    void unionAB();
    void differenceAB();
    void differenceBA();
    void cartesianAB();
    void cartesianBA();
    void editA();
    void editB();
    void viewAB();
    int responseA=0;
    int responseB=0;
    int min=0;
    void string_input_a();
    void string_input_b();
    void output_value_a(int a);
    void output_value_b(int a);
    void output_value_i(int a);
    void output_value_u(int a);
    void output_value_d(int a);
    
    
    int array_a[30]={0};
    int array_b[30]={0};
    int string_length_a;
    int string_length_b;
    int i[60];//={0};
    int u[60]={0};
    int d[60]={0};
    
    int main()
    {
    	int a_number=0;
    	int b_number=0;
    	
    	string_input_a();
    	string_input_b();
    
    	int exitA=0;
    	int exitB=0;	
    
    	menu();
    
    	return 0;
    }
    	
    void menu()
    {
    	int choice=0;
    	int leave=0;
    	cout<<"1. \t The intersection of the sets A and B." <<endl;
    	cout<<"2. \t The union of sets A and B." <<endl;
    	cout<<"3. \t The difference of sets A and B (A-B)." <<endl;
    	cout<<"4. \t The difference of sets B and A (B-A)." <<endl;
    	cout<<"5. \t The Cartesian product AxB." <<endl;
    	cout<<"6. \t The Cartesian product BxA." <<endl;
    	cout<<"7. \t Edit set A." <<endl;
    	cout<<"8. \t Edit set B." <<endl;
    	cout<<"9. \t View sets A and B." <<endl;
    	cout<<"10. \t Exit the program." <<endl;
    	do
    	{
    		cout<<"Make your decision:" <<endl;
    		cin>>choice;
    		if (choice<1||choice>10)
    		{
    			cout<<"Please enter a valid choice!" <<endl;
    			cin>>choice;
    			if (choice>=1&&choice<=10)
    			{
    				leave=1;
    			}
    		}
    		else
    		{
    			leave=1;
    		}
    		if (!cin)
    		{
    			cin.clear();
    		
    		while (cin.get() != '\n')
    		{}
    	
    		continue;
    		}
    	}
    	while (leave!=1);
    
    
    	if (choice>=1&&choice<=10)
    	{
    		if (choice==1)
    		{
    			intersection();
    		}
    		else if(choice==2)
    		{
    			unionAB();
    		}
    		else if(choice==3)
    		{
    			differenceAB();
    		}
    		else if(choice==4)
    		{
    			differenceBA();
    		}
    		else if(choice==5)
    		{
    			cartesianAB();
    		}
    		else if(choice==6)
    		{
    			cartesianBA();
    		}
    		else if(choice==7)
    		{
    			editA();
    		}
    		else if(choice==8)
    		{
    			editB();
    		}
    		else if(choice==9)
    		{
    			viewAB();
    		}
    		else if(choice==10)
    		{
    			exit(1);
    		}
    	}
    	else
    	{
    		cout<<"Please input a valid choice." <<endl;
    		cin>>choice;
    	}
    
    }
    
    void intersection()
    {
    	int number=0;
    	int count=0;
    	int intersect=0;
    	do
    	{
    		i[count]=32000;
    		count++;
    	}
    	while (count<30);
    	count=0;
    	do
    	{
    		do
    		{
    			if (array_a[number]==array_b[count])
    			{
    				i[intersect]=array_a[number];			//this is the line that seems to be causing the problems
    				intersect++;
    			}
    			number++;
    
    		}
    		while (number<30);
    		number=0;
    		count++;
    	}
    	while (count<30);
    
    	number=0;
    	count=1;	
    	
    	do
    	{
    		do
    		{
    			if ((i[number]==i[count])&&(number!=count))
    			{
    				i[count]=99999;
    				count++;
    			}
    			else
    			{
    				count++;
    			}
    		}
    		while (count<30);
    		number++;
    		count=0;
    	}
    	while (number<30);
    	cout<<"The intersection of A and B is:" <<endl;
    	intersect=0;
    	if (i[intersect]==99999)
    	{
    		cout<<"null set" <<endl;
    	}
    	else
    	{
    		cout<<i[intersect];
    		intersect++;
    	}
    	do
    	{
    		if (i[intersect]!=99999)
    		{
    			cout<<", " <<i[intersect];
    			intersect++;
    		}
    	}
    	while (intersect<30&&i[intersect]!=99999);
    	cout<<endl;
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    void unionAB()
    {
    	int number=0;
    	int count=0;
    	int b_number=30;
    	do
    	{
    		u[count]=99999;
    		count++;
    	}
    	while (count<60);
    	count=0;
    	do
    	{
    		u[number]=array_a[number];
    		number++;
    	}
    	while (number<30);
    	number=0;
    	do
    	{
    		u[b_number]=array_b[number];
    		number++;
    		b_number++;
    	}
    	while (number<30);
    	number=0;
    	cout<<endl;
    	number=0;
    	count=30;
    	do
    	{
    
    		do
    		{
    			if (u[number]==u[count])
    			{
    				u[count]=99999;
    			}
    			count++;
    		}
    		while (count<60&&u[number]!=99999);
    		count=30;
    		number++;
    	}
    	while (number<30);
    	cout<<"The union of A and B is:" <<endl;
    	number=0;
    	if (u[number]!=99999)
    	{
    		cout<<u[number];
    		number++;
    	}
    	else
    	{
    		number++;
    	}
    	do
    	{
    		if (u[number]!=99999)
    		{
    			cout<<", " <<u[number];
    		}
    		number++;
    	}
    	while (number<60);
    	cout<<endl;
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    void differenceAB()
    {
    	int count=0;
    	int number=0;
    	int increment=0;
    	int exit=0;
    	do
    	{
    		d[count]=99999;
    		count++;
    	}
    	while (count<60);
    	count=0;
    	
    	do
    	{
    		d[count]=array_a[count];
    		count++;
    	}
    	while (count<30);
    	do
    	{
    		d[count]=array_b[increment];
    		count++;
    		increment++;
    	}
    	while (increment<30);
    	do
    	{
    		count=30;
    		do
    		{
    			if (d[number]==d[count])
    			{
    				d[number]=99999;
    			}
    			count++;
    		}
    		while (count<60);
    		number++;
    	}
    	while (number<30);
    	
    	cout<<"The difference of A-B is:" <<endl;
    	number=0;
    	do
    	{
    		if ((d[number]<32000)&&(d[number]>-32000))
    		{
    			cout<<d[number];
    			number++;
    			exit=1;
    		}
    		else
    		{
    			number++;
    		}
    	}
    	while (exit==0);
    	do
    	{
    		if ((d[number]<32000)&&(d[number]>-32000))
    		{
    			cout<<", " <<d[number] ;
    			number++;
    		}
    		else
    		{
    			number++;
    		}
    	}
    	while (number<30);
    	cout<<endl;
    
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    void differenceBA()
    {
    	int count=0;
    	int number=0;
    	int increment=0;
    	int exit=0;
    	
    	do
    	{
    		d[count]=99999;
    		count++;
    	}
    	while (count<60);
    	count=0;
    	do
    	{
    		d[count]=array_b[count];
    		count++;
    	}
    	while (count<30);
    	do
    	{
    		d[count]=array_a[increment];
    		count++;
    		increment++;
    	}
    	while (increment<30);
    
    	do
    	{
    		count=30;
    		do
    		{
    			if (d[number]==d[count])
    			{
    				d[number]=99999;
    			}
    			count++;
    		}
    		while (count<60);
    		number++;
    	}
    	while (number<30);
    
    	cout<<"The difference of B-A is:" <<endl;
    	increment=0;
    	do
    	{
    		if (d[increment]!=99999)
    		{
    			cout<<d[increment];
    			increment++;
    			exit=1;
    		}
    		else
    		{
    			increment++;
    		}
    	}
    	while (exit==0);
    
    	do
    	{
    		if (d[increment]!=99999)
    		{
    			cout<<", " <<d[increment];
    			increment++;
    		}
    		else
    		{
    			increment++;
    		}
    	}
    	while (increment<30);
    	cout<<endl;
    
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    
    
    void cartesianAB()
    {
    	int increment=0;
    	int count=0;
    	int display_count=0;
    	cout<<"The Cartesian product of AxB is:" <<endl;
    	cout<<"{";
    	do
    	{
    
    		do
    		{
    			if (array_a[increment]!=99999&&array_b[count]!=99999)
    			{
    				cout<<" (" <<array_a[increment] <<" , " <<array_b[count] <<") ";
    				count++;
    				display_count++;
    			}
    			else
    			{
    				count++;
    			}
    			if (display_count==6)
    			{
    				cout<<endl;
    				display_count=0;
    			}
    		}
    		while (count<30);
    		increment++;
    		count=0;
    	}
    	while (increment<30);
    	cout<<"}" <<endl;
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    void cartesianBA()
    {
    	int increment=0;
    	int count=0;
    	int display_count=0;
    	cout<<"The Cartesian product of BxA is:" <<endl;
    	cout<<"{";
    	do
    	{
    
    		do
    		{
    			if (array_a[count]!=99999&&array_b[increment]!=99999)
    			{
    				cout<<" (" <<array_b[increment] <<" , " <<array_a[count] <<") ";
    				count++;
    				display_count++;
    			}
    			else
    			{
    				count++;
    			}
    			if (display_count==6)
    			{
    				cout<<endl;
    				display_count=0;
    			}
    		}
    		while (count<30);
    		increment++;
    		count=0;
    	}
    	while (increment<30);
    	cout<<"}" <<endl;
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    void editA()
    {
    	string_input_a();
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    void editB()
    {
    	string_input_b();
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    void viewAB()
    {
    	int a_number=0;
    	int b_number=0;
    	cout<<"Set A:" <<endl;
    	do
    	{
    		if (array_a[a_number]!=99999)
    		{
    			cout<<array_a[a_number] <<" ";
    			a_number++;
    		}
    		else
    		{
    			a_number++;
    		}
    	}
    	while (a_number<30);
    	cout<<endl;
    
    	cout<<"Set B:" <<endl;
    	do
    	{
    		if (array_b[b_number]!=99999)
    		{
    			cout<<array_b[b_number] <<" ";
    			b_number++;
    		}
    		else
    		{
    			b_number++;
    		}
    	}
    	while (b_number<30);
    	cout<<endl;
    
    	a_number=0;
    	b_number=0;
    
    	system("pause");
    	cout<<endl;
    	menu();
    }
    
    void string_input_a()
    {
    	#include <stdio.h>
    	#include <ctype.h>
    	using namespace std;
    	
    	
    	
    	char input_string[220];
    	int string_length=0;
    	int a=0;
    	int i=0;
    	char read_char=0;
    	bool neg_flag=0;
    	bool first_digit=0;
    	int case_int=0;
    	int number_entered=0;
    	int digit_entered=0;
    	char buffer[1];
    	int all_purpose_counter=0;
    
    	do
    	{
    		array_a[all_purpose_counter]=99999;
    		all_purpose_counter++;
    	}
    	while (all_purpose_counter<=30);
    	all_purpose_counter=0;
    
    	
    	
    	cout<<"Please enter set A in set notation, with possible values between -31,999 and 31,999 (maximum of 30 values)" <<endl;
    	cin.getline(input_string, 220);
    	string_length=strlen(input_string);
    	i=0;
    	do
    	{
    		read_char=input_string[i];
    		if (read_char=='{') case_int=1;
    		if ((isdigit(read_char)!=0)) case_int=2;
    		if (read_char==',') case_int=3;
    		if (read_char=='-') case_int=4;
    		if ((read_char=='}')||(read_char==']')) case_int=5;
    		switch(case_int)
    		{
    			case 1:
    			neg_flag=0;
    			i++;
    			break;
    
    			case 2:
    //		convert read_char to integer
    			if (!first_digit)
    			{
    				number_entered=0;
    				first_digit=1;
    			}
    			buffer[0]=read_char;
    			digit_entered=atoi(buffer);
    			number_entered=number_entered*10+digit_entered;
    			i++;
    			break;
    		
    		case 3:
    //		copy # into array
    			first_digit=0;
    			if (neg_flag)
    			{
    				array_a[a]=number_entered*-1;
    			}
    			else 
    			{
    				array_a[a]=number_entered;
    			}
    			a++;
    			i++;
    			neg_flag=0;
    			break;
    	
    		case 4:
    			neg_flag=1;
    			i++;
    			break;
    		
    	
    		case 5:
    			if (neg_flag)
    			{
    				array_a[a]=number_entered*-1;
    			}
    			else 
    			{
    				array_a[a]=number_entered;
    			}
    			i++;
    			a++;
    			break;
    		}
    	
    	}
    	while (i<string_length);
    	i=0;
    	do
    	{
    		if (((array_a[i]<-31999)||(array_a[i]>31999))&&(array_a[i]!=99999))
    		{
    			cout<<"Please input a valid set consisting of integers between -31,999 and 31,999" <<endl;
    			string_input_a();
    		}
    		i++;
    	}
    	while (i<a);
    	string_length_a=a;
    	i=0;
    }
    
    
    void string_input_b()
    {
    	#include <stdio.h>
    	#include <ctype.h>
    	using namespace std;
    	
    	
    	
    	char input_string[220];
    	int string_length=0;
    	int a=0;
    	int i=0;
    	char read_char=0;
    	bool neg_flag=0;
    	bool first_digit=0;
    	int case_int=0;
    	int number_entered=0;
    	int digit_entered=0;
    	char buffer[1];
    	int all_purpose_counter=0;
    
    	do
    	{
    		array_b[all_purpose_counter]=99999;
    		all_purpose_counter++;
    	}
    	while (all_purpose_counter<=30);
    	all_purpose_counter=0;
    	
    	
    	
    	cout<<"Please enter set B in set notation, with possible values between -31,999 and 31,999 (maximum of 30 values)" <<endl;
    	cin.getline(input_string, 220);
    	string_length=strlen(input_string);
    	i=0;
    	do
    	{
    		read_char=input_string[i];
    		if (read_char=='{') case_int=1;
    		if ((isdigit(read_char)!=0)) case_int=2;
    		if (read_char==',') case_int=3;
    		if (read_char=='-') case_int=4;
    		if ((read_char=='}')||(read_char==']')) case_int=5;
    		switch(case_int)
    		{
    			case 1:
    			neg_flag=0;
    			i++;
    			break;
    
    			case 2:
    //		convert read_char to integer
    			if (!first_digit)
    			{
    				number_entered=0;
    				first_digit=1;
    			}
    			buffer[0]=read_char;
    			digit_entered=atoi(buffer);
    			number_entered=number_entered*10+digit_entered;
    			i++;
    			break;
    		
    		case 3:
    //		copy # into array
    			first_digit=0;
    			if (neg_flag)
    			{
    				array_b[a]=number_entered*-1;
    			}
    			else 
    			{
    				array_b[a]=number_entered;
    			}
    			a++;
    			i++;
    			neg_flag=0;
    			break;
    	
    		case 4:
    			neg_flag=1;
    			i++;
    			break;
    		
    	
    		case 5:
    			if (neg_flag)
    			{
    				array_b[a]=number_entered*-1;
    			}
    			else 
    			{
    				array_b[a]=number_entered;
    			}
    			i++;
    			a++;
    			break;
    		}
    	
    	}
    	while (i<string_length);
    	i=0;
    	do
    	{
    		if (((array_b[i]<-31999)||(array_b[i]>31999))&&(array_b[i]!=99999))
    		{
    			cout<<"Please input a valid set consisting of integers between -31,999 and 31,999" <<endl;
    			string_input_b();
    		}
    		i++;
    	}
    	while (i<a);
    	string_length_b=a;
    }
    
    
    
    
    
    
    
    void output_value_a(int a)
    {
    	if ((array_a[a]<1000)&&(array_a[a]>=0)&&(array_a[a]!=99999))
    	{
    		cout<<array_a[a];
    	}
    	if (((array_a[a]>=1000)&&(array_a[a]!=99999)))
    	{
    		cout<<array_a[a]/1000 <<",";
    		if ((array_a[a]%1000<10)&&(array_a[a]%1000>=0))
    		{
    			cout<<"00" <<array_a[a]%1000;
    		}
    		if ((array_a[a]%1000<100)&&(array_a[a]%1000>10)&&(array_a[a]%1000>=0))
    		{
    			cout<<"0" <<array_a[a]%1000;
    		}
    		if ((array_a[a]%1000<1000)&&(array_a[a]%1000>100)&&(array_a[a]%1000>=0))
    		{
    			cout<<array_a[a]%1000;
    		}
    
    	}
    	if (((array_a[a]<=-1000)&&(array_a[a]!=99999)))
    	{
    		cout<<array_a[a]/1000 <<",";
    		if ((array_a[a]%1000>-10)&&(array_a[a]%1000<0))
    		{
    			cout<<"00" <<(array_a[a]%1000)*-1;
    		}
    		if ((array_a[a]%1000>-100)&&(array_a[a]%1000<-10)&&(array_a[a]%1000<0))
    		{
    			cout<<"0" <<(array_a[a]%1000)*-1;
    		}
    		if ((array_a[a]%1000>-1000)&&(array_a[a]%1000<-100)&&(array_a[a]%1000<0))
    		{
    			cout<<(array_a[a]%1000)*-1;
    		}
    	}
    }
    
    
    
    void output_value_b(int a)
    {
    	if ((array_b[a]<1000)&&(array_b[a]>=0)&&(array_b[a]!=99999))
    	{
    		cout<<array_b[a];
    	}
    	if (((array_b[a]>=1000)&&(array_b[a]!=99999)))
    	{
    		cout<<array_b[a]/1000 <<",";
    		if ((array_b[a]%1000<10)&&(array_b[a]%1000>=0))
    		{
    			cout<<"00" <<array_b[a]%1000;
    		}
    		if ((array_b[a]%1000<100)&&(array_b[a]%1000>10)&&(array_b[a]%1000>=0))
    		{
    			cout<<"0" <<array_b[a]%1000;
    		}
    		if ((array_b[a]%1000<1000)&&(array_b[a]%1000>100)&&(array_b[a]%1000>=0))
    		{
    			cout<<array_b[a]%1000;
    		}
    
    	}
    	if (((array_b[a]<=-1000)&&(array_b[a]!=99999)))
    	{
    		cout<<array_b[a]/1000 <<",";
    		if ((array_b[a]%1000>-10)&&(array_b[a]%1000<0))
    		{
    			cout<<"00" <<(array_b[a]%1000)*-1;
    		}
    		if ((array_b[a]%1000>-100)&&(array_b[a]%1000<-10)&&(array_b[a]%1000<0))
    		{
    			cout<<"0" <<(array_b[a]%1000)*-1;
    		}
    		if ((array_b[a]%1000>-1000)&&(array_b[a]%1000<-100)&&(array_b[a]%1000<0))
    		{
    			cout<<(array_b[a]%1000)*-1;
    		}
    	}
    }
    
    void output_value_i(int a)
    {
    	if ((i[a]<1000)&&(i[a]>=0)&&(i[a]!=99999))
    	{
    		cout<<i[a];
    	}
    	if (((i[a]>=1000)&&(i[a]!=99999)))
    	{
    		cout<<i[a]/1000 <<",";
    		if ((i[a]%1000<10)&&(i[a]%1000>=0))
    		{
    			cout<<"00" <<i[a]%1000;
    		}
    		if ((i[a]%1000<100)&&(i[a]%1000>10)&&(i[a]%1000>=0))
    		{
    			cout<<"0" <<i[a]%1000;
    		}
    		if ((i[a]%1000<1000)&&(i[a]%1000>100)&&(i[a]%1000>=0))
    		{
    			cout<<i[a]%1000;
    		}
    
    	}
    	if (((i[a]<=-1000)&&(i[a]!=99999)))
    	{
    		cout<<i[a]/1000 <<",";
    		if ((i[a]%1000>-10)&&(i[a]%1000<0))
    		{
    			cout<<"00" <<(i[a]%1000)*-1;
    		}
    		if ((i[a]%1000>-100)&&(i[a]%1000<-10)&&(i[a]%1000<0))
    		{
    			cout<<"0" <<(i[a]%1000)*-1;
    		}
    		if ((i[a]%1000>-1000)&&(i[a]%1000<-100)&&(i[a]%1000<0))
    		{
    			cout<<(i[a]%1000)*-1;
    		}
    	}
    }
    
    void output_value_u(int a)
    {
    	if ((u[a]<1000)&&(u[a]>=0)&&(u[a]!=99999))
    	{
    		cout<<u[a];
    	}
    	if (((u[a]>=1000)&&(u[a]!=99999)))
    	{
    		cout<<u[a]/1000 <<",";
    		if ((u[a]%1000<10)&&(u[a]%1000>=0))
    		{
    			cout<<"00" <<u[a]%1000;
    		}
    		if ((u[a]%1000<100)&&(u[a]%1000>10)&&(u[a]%1000>=0))
    		{
    			cout<<"0" <<u[a]%1000;
    		}
    		if ((u[a]%1000<1000)&&(u[a]%1000>100)&&(u[a]%1000>=0))
    		{
    			cout<<u[a]%1000;
    		}
    
    	}
    	if (((u[a]<=-1000)&&(u[a]!=99999)))
    	{
    		cout<<u[a]/1000 <<",";
    		if ((u[a]%1000>-10)&&(u[a]%1000<0))
    		{
    			cout<<"00" <<(u[a]%1000)*-1;
    		}
    		if ((u[a]%1000>-100)&&(u[a]%1000<-10)&&(u[a]%1000<0))
    		{
    			cout<<"0" <<(u[a]%1000)*-1;
    		}
    		if ((u[a]%1000>-1000)&&(u[a]%1000<-100)&&(u[a]%1000<0))
    		{
    			cout<<(u[a]%1000)*-1;
    		}
    	}
    }
    
    void output_value_d(int a)
    {
    	if ((d[a]<1000)&&(d[a]>=0)&&(d[a]!=99999))
    	{
    		cout<<d[a];
    	}
    	if (((d[a]>=1000)&&(d[a]!=99999)))
    	{
    		cout<<d[a]/1000 <<",";
    		if ((d[a]%1000<10)&&(d[a]%1000>=0))
    		{
    			cout<<"00" <<d[a]%1000;
    		}
    		if ((d[a]%1000<100)&&(d[a]%1000>10)&&(d[a]%1000>=0))
    		{
    			cout<<"0" <<d[a]%1000;
    		}
    		if ((d[a]%1000<1000)&&(d[a]%1000>100)&&(d[a]%1000>=0))
    		{
    			cout<<d[a]%1000;
    		}
    
    	}
    	if (((d[a]<=-1000)&&(d[a]!=99999)))
    	{
    		cout<<d[a]/1000 <<",";
    		if ((d[a]%1000>-10)&&(d[a]%1000<0))
    		{
    			cout<<"00" <<(d[a]%1000)*-1;
    		}
    		if ((d[a]%1000>-100)&&(d[a]%1000<-10)&&(d[a]%1000<0))
    		{
    			cout<<"0" <<(d[a]%1000)*-1;
    		}
    		if ((d[a]%1000>-1000)&&(d[a]%1000<-100)&&(d[a]%1000<0))
    		{
    			cout<<(d[a]%1000)*-1;
    		}
    	}
    }

  13. #13
    Registered User
    Join Date
    Oct 2002
    Posts
    69
    bump

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  3. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  4. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM