Results 1 to 5 of 5
  1. #1

    Angry Ngano dli mogana ako code? Palihug tabang!


    Ang problema man gud ani...kinanglan ang input sa sets naa sa universal...kung dli mao ang input kinahanglan mangayo siya ug usob....

    Code:
    import java.io.*;
    
    public class ProjectMenu{
    	public static void main (String[]args)throws Exception
    	{
    		BufferedReader input=new BufferedReader(new	InputStreamReader(System.in));
    		int option,n1,n2,n3,x=0,y=0,flag,uni;
    		System.out.print("\n\n\t\t\t***CS 212 PROJECT***\n");
    		System.out.print("\n\n\t\t\t       Group 3\n");
    
    		System.out.print("\t\t\t  Set of Operation\n\n");
    
    		System.out.print("\t        Union, Intersection and Relative Complement\n\n");
    		do{
    		System.out.print("Enter number of elements to input in Universal:");
    		uni=Integer.parseInt(input.readLine());
    		}while((uni<1)||(uni>8));
    
    		char univer[]=new char[uni];
    		System.out.print("Enter elements of Universal:\n");
    		for(x=0;x<uni;x++)
    			{
    						System.out.print("Element["+x+"] ");
    						univer[x]=(char)System.in.read();
    						System.in.read();
    						System.in.read();
                }
    
    		do{
    		System.out.print("Enter number of elements to input in Set A: ");
    		n1=Integer.parseInt(input.readLine());
    		}while((n1>3)||(n1<1));
    		char seta[]=new char[n1];
    		System.out.print("Enter elements of Set A: \n");
    		for(x=0;x<seta.length;x++)
    			{
    				y=0;
    				do{
    				System.out.print("Element: ");
    				seta[x]=(char)System.in.read();
    				System.in.read();
    				System.in.read();
    				y++;
    				}while(seta[x]!=univer[y]);
    			}
    		do{
    		System.out.print("\nEnter number of elements to input in Set B: ");
    		n2=Integer.parseInt(input.readLine());
    		}while((n2>3)||(n2<1));
    		char setb[]=new char[n2];
    		System.out.print("Enter elements of Set B: \n");
    		for(x=0;x<setb.length;x++)
    			{
    				System.out.print("Element ["+x+"]");
    				setb[x]=(char)System.in.read();
    				System.in.read();
    				System.in.read();
    
    			}
    		do{
    			System.out.print("\nEnter number of elements to input in Set C: ");
    		n3=Integer.parseInt(input.readLine());
    		}while((n3>3)||(n3<1));
    		char setc[]=new char[n3];
    		System.out.print("Enter elements of Set B: \n");
    		for(x=0;x<setc.length;x++)
    			{
    				System.out.print("Element ["+x+"] ");
    				setc[x]=(char)System.in.read();
    				System.in.read();
    				System.in.read();
    			}
    		System.out.print("\nSet A:\t ");
    		for(x=0;x<n1;x++)
    			{
    				System.out.print(seta[x]+" ");
    			}
    		System.out.print("\nSet B:\t ");
    			for(x=0;x<n2;x++)
    				{
    					System.out.print(setb[x]+" ");
    				}
    		System.out.print("\nSet C:\t ");
    			for(x=0;x<n3;x++)
    				{
    					System.out.print(setc[x]+" ");
    				}
    		while(true)
    		{
    		do{
    			System.out.print("\n\n\tMenu: ");
    			System.out.print("\n\t[1]Union: ");
    			System.out.print("\n\t[2]Intersection: ");
    			System.out.print("\n\t[3]Relative Complement: ");
    			System.out.print("\nPlease Select(1,2,3): ");
    			option=Integer.parseInt(input.readLine());
    
    			if(option==1)
    				union(seta,setb,setc,n1,n2,n3);
    			else if(option==2)
    				intersection(seta,setb,setc,n1,n2,n3);
    			else if(option==3)
    				relative(seta,setb,setc,n1,n2,n3);
    			else
    				System.out.print("invalid input");
    
    			}while((option>4)||(option<1));
    		}
    
    	}
    public static void union(char seta[], char setb[], char setc[],int n1, int n2, int n3)throws Exception
    	{
    		BufferedReader input=new BufferedReader(new 					InputStreamReader(System.in));
    		char un1[]=new char[n1+n2];
    		char un2[]=new char[n1+n3];
    		char un3[]=new char[n2+n3];
    		char op;
    		int ch1,x,y;
    		do{
    		int i=0;
    		System.out.print("\n\nU N I O N");
    		System.out.print("\n[1]AUB");
    		System.out.print("\n[2]AUC");
    		System.out.print("\n[3]BUC");
    		System.out.print("\nPlease select: ");
    		ch1=Integer.parseInt(input.readLine());
    		if(ch1==1)
    			{
    			System.out.print("\nUnion (AUB) = { ");
    			for(x=0;x<n1;x++)
    				{
    				    for(y=0;y<n2;y++)
    				    {
    					        if(seta[x]!=setb[y])
    						{
    					         un1[i]=seta[x];
    					        }
    					        else
    					        	un1[i]=seta[x];
    					}
    						i++;
    				}
    
    
    			for(x=0;x<n2;x++)
    				{
    				   for(y=0;y<n1;y++)
    					  {
    					   if(setb[x]!=seta[y])
    					{
    					  un1[i]=setb[x];
    					 }
    					else
    					{
    					 i--;
    					 break;
    					}
    					}
    					i++;
    					}
    
    			for(i=0;i<un1.length;i++)
    			    {
    			         System.out.print(un1[i]);
    			     }
    			System.out.print(" }");
    			}
    	else if(ch1==2)
    		{
         		System.out.print("\nUnion (AUC) = { ");
    			for(x=0;x<n1;x++)
    				{
    				    for(y=0;y<n3;y++)
    					    {
    					        if(seta[x]!=setc[y])
    						{
    					         un2[i]=seta[x];
    					        }
    					        else
    					        	un2[i]=seta[x];
    						}
    					i++;
    				}
    
    			for(x=0;x<n3;x++)
    				{
    					   for(y=0;y<n1;y++)
    						  {
    							   if(setc[x]!=seta[y])
    							{
    							  un2[i]=setc[x];
    						        }
    							else
    									{
    											  i--;
    											  break;
    											}
    									}
    							i++;
    							}
    
    
    						for(i=0;i<un2.length;i++)
    						    {
    						         System.out.print(un2[i]);
    						     }
    
    System.out.print(" }");
    					}
    					else if(ch1==3)
    						{
    							System.out.print("\nUnion (BUC) = { ");
    							for(x=0;x<n2;x++)
    								{
    								    for(y=0;y<n3;y++)
    									    {
    									        if(setb[x]!=setc[y])
    												{
    											         un3[i]=setb[x];
    										        }
    									        else
    									        	un3[i]=setb[x];
    										}
    										i++;
    								}
    
    
    							for(x=0;x<n3;x++)
    								{
    								   for(y=0;y<n2;y++)
    									  {
    										   if(setc[x]!=setb[y])
    												{
    											  un3[i]=setc[x];
    										        }
    											else
    												{
    													  i--;
    													  break;
    												}
    										}
    							   	i++;
    								}
    
    
    							for(i=0;i<un3.length;i++)
    							    {
    							         System.out.print(un3[i]);
    							     }
    						System.out.print(" }");
    					}
    				else
    						{
    					System.out.print("Invalid input!");
    						}
    			System.out.print("\n\nBack to Union menu[Y\\N]?");
    			op=Character.toUpperCase((char)System.in.read());
    			System.in.read();
    			System.in.read();
    			}while(op=='Y');
    			}
    		public static void intersection(char seta[], char setb[], char setc[],int n1, int n2, int n3)throws Exception
    			{
    				BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
    				char op;
    				int ch1=0, x, y;
    				do{
    				System.out.print("\n\nI N T E R S E C T I O N");
    				System.out.print("\n[1]AB");
    				System.out.print("\n[2]AC");
    				System.out.print("\n[3]BC");
    				System.out.print("\nPlease select: ");
    				ch1=Integer.parseInt(input.readLine());
    				switch(ch1){
    					case 1:
    						System.out.print("\n\nIntersection (AB) =\t{ ");
    						for(x=0;x<n1;x++)
    							{
    								for(y=0;y<n2;y++)
    									{
    										if(seta[x]==setb[y])
    										System.out.print(seta[x]+" ");
    									else
    										continue;
    									}
    							}
    						System.out.print(" }");
    					break;
    					case 2:
    						System.out.print("\n\nIntersection (AC) =\t{ ");
    						for(x=0;x<n1;x++)
    							{
    								for(y=0;y<n3;y++)
    									{
    										if(seta[x]==setc[y])
    											System.out.print(seta[x]+" ");
    										else
    											continue;
    									}
    							}
    						System.out.print(" }");
    					break;
    					case 3:
    					System.out.print("\n\nIntersection (BC) =\t{ ");
    						for(x=0;x<n2;x++)
    							{
    								for(y=0;y<n3;y++)
    									{
    										if(setb[x]==setc[y])
    											System.out.print(setb[x]+" ");
    										else
    											continue;
    									}
    							}
    						System.out.print(" }");
    					break;
    					default:
    						System.out.print("Invalid input");
    											break;
    					}
    			System.out.print("\n\nBack to Intersection menu[Y\\N]?");
    			op=Character.toUpperCase((char)System.in.read());
    			System.in.read();
    			System.in.read();
    				}while((op=='y')||(op=='Y'));
    
    			}
    
    		public static void relative(char seta[], char setb[], char setc[],int n1, int n2, int n3)throws Exception
    			{
    				BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
    
    				char op;
    				int ch1, x, y;
    				do{
    				ch1=0;
    				System.out.print("\n\nR E L A T I V E");
    				System.out.print("\n\n[1]A-B");
    				System.out.print("\n[2]A-C");
    				System.out.print("\n[3]B-C");
    				System.out.print("\n[4]B-A");
    				System.out.print("\n[5]C-A");
    				System.out.print("\n[6]C-B");
    				System.out.print("\nPlease select: ");
    				ch1=Integer.parseInt(input.readLine());
    				switch(ch1){
    					case 1:
    							System.out.print("\nRelative(A-B) = { ");
    							for(x=0;x<n1;x++)
    								{
    									for(y=n2-1;y>=0;y--)
    										{
    										if(seta[x]==setb[y])
    											{
    											x=x+1;
    											y=n2-1;
    											}
    										}
    									if(x<n1)
    								System.out.print(seta[x]);
    								}
    							System.out.print(" }");
    					break;
    					case 2:
    							System.out.print("\nRelative(A-C) = \t{ ");
    							for(x=0;x<n1;x++)
    								{
    									for(y=n3-1;y>=0;y--)
    										{
    										if(seta[x]==setc[y])
    											{
    											x=x+1;
    											y=n3-1;
    											}
    										}
    								if(x<n1)
    								System.out.print(seta[x]);
    
    								}
    							System.out.print(" }");
    					break;
    					case 3:
    							System.out.print("\nRelative(B-C) = \t{ ");
    							for(x=0;x<n2;x++)
    								{
    									for(y=n3-1;y>=0;y--)
    										{
    										if(setb[x]==setc[y])
    											{
    											x=x+1;
    											y=n3-1;
    											}
    										}
    								if(x<n2)
    								System.out.print(setb[x]);
    								}
    							System.out.print(" }");
    					break;
    					case 4:
    							System.out.print("\nRelative(B-A) = \t{ ");
    							for(x=0;x<n2;x++)
    								{
    									for(y=n1-1;y>=0;y--)
    										{
    										if(setb[x]==seta[y])
    											{
    											x=x+1;
    											y=n1-1;
    											}
    										}
    								if(x<n2)
    								System.out.print(setb[x]);
    								}
    							System.out.print(" }");
    					break;
    					case 5:
    							System.out.print("\nRelative(C-A) = \t{ ");
    							for(x=0;x<n3;x++)
    								{
    									for(y=n1-1 ;y>=0;y--)
    										{
    										if(setc[x]==seta[y])
    											{
    											x=x+1;
    											y=n1-1;
    											}
    										}
    								if(x<n3)
    								System.out.print(setc[x]);
    								}
    							System.out.print(" }");
    					break;
    					case 6:
    							System.out.print("\nRelative(C-B) = \t{ ");
    							for(x=0;x<n3;x++)
    								{
    									for(y=n2-1 ;y>=0;y--)
    										{
    										if(setc[x]==setb[y])
    											{
    											x=x+1;
    											y=n2-1;
    											}
    										}
    							if(x<n3)
    								System.out.print(setc[x]);
    								}
    							System.out.print(" }");
    					break;
    
    				default:
    					System.out.print("Invalid input!");
    					break;
    				}
    			System.out.print("\n\nBack to Relative menu[Y\\N]?");
    			op=Character.toUpperCase((char)System.in.read());
    			System.in.read();
    			System.in.read();
    				}while((op=='y')||(op=='Y'));
    			}
    	}

  2. #2
    unsa raman ang error bai?

  3. #3
    Junior Member Premium Member
    Join Date
    Jun 2010
    Gender
    Female
    Posts
    126
    Blog Entries
    10
    sige man gud ka istorya. hehe. jowk.

  4. #4
    sulbad na ni?

  5. #5
    kung wa pa gani ni ma-solve palihug lang ko check ani bro... dinalian ni nga fix.. daghan pa kulang sa code... for example, error-handling kay prone to errors ang user input. unya kinghanlan pa i-optimize ang algorithm nga gipanggamit kay daghan redundant steps.

    Code:
    import java.io.*;
    
    public class ProjectMenu
    {
    	public static void main(String[]args) throws Exception
    	{
    		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    		int option, n1, n2, n3, x = 0, y = 0, flag, uni;
    		System.out.print("\n\n\t\t\t***CS 212 PROJECT***\n");
    		System.out.print("\n\n\t\t\t       Group 3\n");
    		System.out.print("\t\t\t  Set of Operation\n\n");
    		System.out.print("\t        Union, Intersection and Relative Complement\n\n");
    
    		do
    		{
    			System.out.print("Enter number of elements to input in Universal:");
    			uni = Integer.parseInt(input.readLine());
    		}
    		while((uni < 1) ||(uni > 8));
    
    		char univer[] = new char[uni];
    		System.out.print("Enter elements of Universal:\n");
    
    		for(x = 0; x < uni; x++)
    		{
    			System.out.print("Element[" + x + "] ");
    			univer[x] = (char) input.read();
    
    			while(input.read() == -1);
    		}
    
    		do
    		{
    			System.out.print("Enter number of elements to input in Set A: ");
    			n1 = Integer.parseInt(input.readLine());
    		}
    		while((n1 > 3) ||(n1 < 1));
    
    		char seta[] = new char[n1];
    		System.out.println("Enter elements of Set A:");
    
    		for(x = 0; x < seta.length; x++)
    		{
    			boolean e = false;
    
    			while (!e)
    			{
    				System.out.print("Element: ");
    				seta[x] = (char) input.read();
    
    				while(input.read() == -1);
    
    				for(y = 0; y < univer.length; y++)
    				{
    					if (univer[y] == seta[x])
    					{
    						e = true;
    						break;
    					}
    				}
    
    				if (!e)
    				{
    					System.out.println("Element does not exist in the Universal Set.");
    				}
    			}
    		}
    
    		do
    		{
    			System.out.print("\nEnter number of elements to input in Set B: ");
    			n2 = Integer.parseInt(input.readLine());
    		}
    		while((n2 > 3) || (n2 < 1));
    
    		char setb[] = new char[n2];
    		System.out.println("Enter elements of Set B:");
    
    		for(x = 0; x < setb.length; x++)
    		{
    			boolean e = false;
    
    			while (!e)
    			{
    				System.out.print("Element: ");
    				setb[x] = (char) input.read();
    
    				while(input.read() == -1);
    
    				for(y = 0; y < univer.length; y++)
    				{
    					if (univer[y] == setb[x])
    					{
    						e = true;
    						break;
    					}
    				}
    
    				if (!e)
    				{
    					System.out.println("Element does not exist in the Universal Set.");
    				}
    			}
    		}
    
    		do
    		{
    			System.out.print("\nEnter number of elements to input in Set C: ");
    			n3 = Integer.parseInt(input.readLine());
    		}
    		while((n3 > 3) || (n3 < 1));
    
    		char setc[] = new char[n3];
    		System.out.print("Enter elements of Set C: \n");
    
    		for(x = 0; x < setc.length; x++)
    		{
    			boolean e = false;
    
    			while (!e)
    			{
    				System.out.print("Element: ");
    				setc[x] = (char) input.read();
    
    				while(input.read() == -1);
    
    				for(y = 0; y < univer.length; y++)
    				{
    					if (univer[y] == setc[x])
    					{
    						e = true;
    						break;
    					}
    				}
    
    				if (!e)
    				{
    					System.out.println("Element does not exist in the Universal Set.");
    				}
    			}
    		}
    
    		System.out.print("\nSet A:\t ");
    
    		for(x = 0; x < n1; x++)
    		{
    			System.out.print(seta[x] + " ");
    		}
    
    		System.out.print("\nSet B:\t ");
    
    		for(x = 0; x < n2; x++)
    		{
    			System.out.print(setb[x] + " ");
    		}
    
    		System.out.print("\nSet C:\t ");
    
    		for(x = 0; x < n3; x++)
    		{
    			System.out.print(setc[x] + " ");
    		}
    
    		while(true)
    		{
    			do
    			{
    				System.out.print("\n\n\tMenu: ");
    				System.out.print("\n\t[1]Union: ");
    				System.out.print("\n\t[2]Intersection: ");
    				System.out.print("\n\t[3]Relative Complement: ");
    				System.out.print("\nPlease Select(1,2,3): ");
    				option = Integer.parseInt(input.readLine());
    
    				if(option == 1)
    					union(seta, setb, setc, n1, n2, n3);
    				else if(option == 2)
    					intersection(seta, setb, setc, n1, n2, n3);
    				else if(option == 3)
    					relative(seta, setb, setc, n1, n2, n3);
    				else
    					System.out.print("invalid input");
    			}
    			while((option > 4) || (option < 1));
    		}
    	}
    
    
    	public static void union(char seta[], char setb[], char setc[], int n1,
    	                          int n2, int n3) throws Exception
    	{
    		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    		char un1[] = new char[n1 + n2];
    		char un2[] = new char[n1 + n3];
    		char un3[] = new char[n2 + n3];
    		char op;
    		int ch1, x, y;
    
    		do
    		{
    			int i = 0;
    			System.out.print("\n\nU N I O N");
    			System.out.print("\n[1]AUB");
    			System.out.print("\n[2]AUC");
    			System.out.print("\n[3]BUC");
    			System.out.print("\nPlease select: ");
    			ch1 = Integer.parseInt(input.readLine());
    
    			if(ch1 == 1)
    			{
    				System.out.print("\nUnion(AUB) = { ");
    
    				for(x = 0; x < n1; x++)
    				{
    					for(y = 0; y < n2; y++)
    					{
    						if(seta[x] != setb[y])
    						{
    							un1[i] = seta[x];
    						}
    						else
    							un1[i] = seta[x];
    					}
    
    					i++;
    				}
    
    				for(x = 0; x < n2; x++)
    				{
    					for(y = 0; y < n1; y++)
    					{
    						if(setb[x] != seta[y])
    						{
    							un1[i] = setb[x];
    						}
    						else
    						{
    							i--;
    							break;
    						}
    					}
    
    					i++;
    				}
    
    				for(i = 0; i < un1.length; i++)
    				{
    					System.out.print(un1[i]);
    				}
    
    				System.out.print(" }");
    			}
    			else if(ch1 == 2)
    			{
    				System.out.print("\nUnion(AUC) = { ");
    
    				for(x = 0; x < n1; x++)
    				{
    					for(y = 0; y < n3; y++)
    					{
    						if(seta[x] != setc[y])
    						{
    							un2[i] = seta[x];
    						}
    						else
    							un2[i] = seta[x];
    					}
    
    					i++;
    				}
    
    				for(x = 0; x < n3; x++)
    				{
    					for(y = 0; y < n1; y++)
    					{
    						if(setc[x] != seta[y])
    						{
    							un2[i] = setc[x];
    						}
    						else
    						{
    							i--;
    							break;
    						}
    					}
    
    					i++;
    				}
    
    				for(i = 0; i < un2.length; i++)
    				{
    					System.out.print(un2[i]);
    				}
    
    				System.out.print(" }");
    			}
    			else if(ch1 == 3)
    			{
    				System.out.print("\nUnion(BUC) = { ");
    
    				for(x = 0; x < n2; x++)
    				{
    					for(y = 0; y < n3; y++)
    					{
    						if(setb[x] != setc[y])
    						{
    							un3[i] = setb[x];
    						}
    						else
    							un3[i] = setb[x];
    					}
    
    					i++;
    				}
    
    				for(x = 0; x < n3; x++)
    				{
    					for(y = 0; y < n2; y++)
    					{
    						if(setc[x] != setb[y])
    						{
    							un3[i] = setc[x];
    						}
    						else
    						{
    							i--;
    							break;
    						}
    					}
    
    					i++;
    				}
    
    				for(i = 0; i < un3.length; i++)
    				{
    					System.out.print(un3[i]);
    				}
    
    				System.out.print(" }");
    			}
    			else
    			{
    				System.out.print("Invalid input!");
    			}
    
    			System.out.print("\n\nBack to Union menu[Y\\N]?");
    			op = Character.toUpperCase((char) input.read());
    			while(input.read() == -1);
    		}
    		while(op == 'Y');
    	}
    
    
    	public static void intersection(char seta[], char setb[], char setc[],
    	                                 int n1, int n2, int n3) throws Exception
    	{
    		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    		char op;
    		int ch1 = 0, x, y;
    
    		do
    		{
    			System.out.print("\n\nI N T E R S E C T I O N");
    			System.out.print("\n[1]AB");
    			System.out.print("\n[2]AC");
    			System.out.print("\n[3]BC");
    			System.out.print("\nPlease select: ");
    			ch1 = Integer.parseInt(input.readLine());
    
    			switch(ch1)
    			{
    			case 1:
    				System.out.print("\n\nIntersection(AB) =\t{ ");
    
    				for(x = 0; x < n1; x++)
    				{
    					for(y = 0; y < n2; y++)
    					{
    						if(seta[x] == setb[y])
    							System.out.print(seta[x] + " ");
    						else
    							continue;
    					}
    				}
    
    				System.out.print(" }");
    				break;
    			case 2:
    				System.out.print("\n\nIntersection(AC) =\t{ ");
    
    				for(x = 0; x < n1; x++)
    				{
    					for(y = 0; y < n3; y++)
    					{
    						if(seta[x] == setc[y])
    							System.out.print(seta[x] + " ");
    						else
    							continue;
    					}
    				}
    
    				System.out.print(" }");
    				break;
    			case 3:
    				System.out.print("\n\nIntersection(BC) =\t{ ");
    
    				for(x = 0; x < n2; x++)
    				{
    					for(y = 0; y < n3; y++)
    					{
    						if(setb[x] == setc[y])
    							System.out.print(setb[x] + " ");
    						else
    							continue;
    					}
    				}
    
    				System.out.print(" }");
    				break;
    			default:
    				System.out.print("Invalid input");
    				break;
    			}
    
    			System.out.print("\n\nBack to Intersection menu[Y\\N]?");
    			op = Character.toUpperCase((char) input.read());
    			while(input.read() == -1);
    		}
    		while((op == 'y') ||(op == 'Y'));
    	}
    
    
    	public static void relative(char seta[], char setb[], char setc[], int n1, int n2, int n3) throws Exception
    	{
    		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    		char op;
    		int ch1, x, y;
    
    		do
    		{
    			ch1 = 0;
    			System.out.print("\n\nR E L A T I V E");
    			System.out.print("\n\n[1]A-B");
    			System.out.print("\n[2]A-C");
    			System.out.print("\n[3]B-C");
    			System.out.print("\n[4]B-A");
    			System.out.print("\n[5]C-A");
    			System.out.print("\n[6]C-B");
    			System.out.print("\nPlease select: ");
    			ch1 = Integer.parseInt(input.readLine());
    
    			switch(ch1)
    			{
    			case 1:
    				System.out.print("\nRelative(A-B) = { ");
    
    				for(x = 0; x < n1; x++)
    				{
    					for(y = n2 - 1; y >= 0; y--)
    					{
    						if(seta[x] == setb[y])
    						{
    							x = x + 1;
    							y = n2 - 1;
    						}
    					}
    
    					if(x < n1)
    						System.out.print(seta[x]);
    				}
    
    				System.out.print(" }");
    				break;
    			case 2:
    				System.out.print("\nRelative(A-C) = \t{ ");
    
    				for(x = 0; x < n1; x++)
    				{
    					for(y = n3 - 1; y >= 0; y--)
    					{
    						if(seta[x] == setc[y])
    						{
    							x = x + 1;
    							y = n3 - 1;
    						}
    					}
    
    					if(x < n1)
    						System.out.print(seta[x]);
    				}
    
    				System.out.print(" }");
    				break;
    			case 3:
    				System.out.print("\nRelative(B-C) = \t{ ");
    
    				for(x = 0; x < n2; x++)
    				{
    					for(y = n3 - 1; y >= 0; y--)
    					{
    						if(setb[x] == setc[y])
    						{
    							x = x + 1;
    							y = n3 - 1;
    						}
    					}
    
    					if(x < n2)
    						System.out.print(setb[x]);
    				}
    
    				System.out.print(" }");
    				break;
    			case 4:
    				System.out.print("\nRelative(B-A) = \t{ ");
    
    				for(x = 0; x < n2; x++)
    				{
    					for(y = n1 - 1; y >= 0; y--)
    					{
    						if(setb[x] == seta[y])
    						{
    							x = x + 1;
    							y = n1 - 1;
    						}
    					}
    
    					if(x < n2)
    						System.out.print(setb[x]);
    				}
    
    				System.out.print(" }");
    				break;
    			case 5:
    				System.out.print("\nRelative(C-A) = \t{ ");
    
    				for(x = 0; x < n3; x++)
    				{
    					for(y = n1 - 1; y >= 0; y--)
    					{
    						if(setc[x] == seta[y])
    						{
    							x = x + 1;
    							y = n1 - 1;
    						}
    					}
    
    					if(x < n3)
    						System.out.print(setc[x]);
    				}
    
    				System.out.print(" }");
    				break;
    			case 6:
    				System.out.print("\nRelative(C-B) = \t{ ");
    
    				for(x = 0; x < n3; x++)
    				{
    					for(y = n2 - 1; y >= 0; y--)
    					{
    						if(setc[x] == setb[y])
    						{
    							x = x + 1;
    							y = n2 - 1;
    						}
    					}
    
    					if(x < n3)
    						System.out.print(setc[x]);
    				}
    
    				System.out.print(" }");
    				break;
    			default:
    				System.out.print("Invalid input!");
    				break;
    			}
    
    			System.out.print("\n\nBack to Relative menu[Y\\N]?");
    			op = Character.toUpperCase((char) input.read());
    
    			while(input.read() == -1);
    		}
    		while((op == 'y') || (op == 'Y'));
    	}
    }
    wa na lang pud nko gi-check ang algorithm para sa set ops kay i know kabalo na mo unsaon na. anyway, sulti lang kung kinghanlan ug additional fix.

  6.    Advertisement

Similar Threads

 
  1. Ngano ma-inlab ako sa mga Taken?
    By WengIA in forum Relationships (Old)
    Replies: 199
    Last Post: 06-15-2010, 06:46 PM
  2. Ako Quetzal nasakit... tabang mga cichlid experts!!!
    By nadzinadz in forum Pet Discussions
    Replies: 7
    Last Post: 09-14-2009, 01:39 PM
  3. Replies: 9
    Last Post: 02-18-2009, 12:38 AM
  4. ngano gi-merged ako thread??
    By shinkei in forum Support Center
    Replies: 2
    Last Post: 03-31-2008, 03:38 PM
  5. ngano dli namn ko ka post sa Buy / Sell / Trade / Classifieds
    By red_kline in forum Networking & Internet
    Replies: 14
    Last Post: 01-10-2007, 04:22 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top