This is only a part of the permutation program......... PHP: void Permute::permute(int start,int num) { static int row = 0, col = 0; // row number & coloumn number. if (num == 1) { // print the word. if (col == 0) { cout << " " << flush; col += 3; } cout << s << " " << flush; col += strlen(s)+3; if (col + strlen(s) + 3 > 79) { // A line is full. Go to next line. cout << endl; col = 0; row++; } if (row > 23 && strlen(s) < 8) { // A Screen is ful. Pause and go to next screen. getch(); system("cls"); row = col = 0; } count++; // increase count. } else { int f[26]; // frequency of alphabets. // initially set all values to 0. for (int i = 0; i < 26; i++) f[i] = 0; for (i = start; s[i] != '\0'; i++) { char c = tolower(s[i]); if (f[c-97] != 0) // if repetation has occured. continue; f[c-97]++; swap(i,start); permute(start+1,num-1); swap(i,start); } } } And can u be a bit more clear on what mathematics operators do we have to write.....There are many operators and all of them should'nt be asked if it was given in an exam....
i meant all mathematical operators ...and oh that was the QUESTION ...cant use any mathematical operators ....and btw it was an exam .. they can ask anything from C++ .... thats what the exam was for ...... neway ..thought of solutions ????
And i still haven't got the previous question .. and its solutions ... be a bit more descriptive on the question please ....
I mean what mathematics operators??? There are many of them.....and many new operators emerging everyday.... I mean is it only.............. +,-,mod,/,*,square root,power,.........OR integration,differentiation,Laplace, Or maybe say the D operator, ....etc
deathvirus u posted a code just before this page ......... Can u edit the code and add the [ php ] [ /php ] tags before and after it (without the spaces) ........ it makes the code much more readable.......
Here's a program that implements threads to search using java : PHP: //To implement multiple threads to search in an array import java.io.*; class threads extends Thread{ int n; threads (int n) { this.n = n; } public void run(){ if(mainclass.find==n) mainclass.position=mainclass.index+1; mainclass.index++; } } class mainclass{ static int arr[]=new int[200]; static int find=0,index=0,position=-1,total=0; public static void main(String args[])throws IOException{ DataInputStream di=new DataInputStream(System.in); System.out.print("Enter total number of elements : "); mainclass.total=Integer.parseInt(di.readLine()); threads a[]=new threads[mainclass.total]; for(int i=0;i<mainclass.total;i++){ System.out.print("Enter element "+(i+1)+" : "); a[i]=new threads(new Integer(di.readLine()).intValue()); } System.out.print("Enter element to search : "); mainclass.find=new Integer(di.readLine()).intValue(); for(int i=0;i<a.length;i++) a[i].start(); label : while(mainclass.index<mainclass.total && mainclass.position<0) continue label; if(mainclass.position<0) System.out.println("Element not present."); else System.out.println("Element present at "+(position)); } } This is still is in bases ... i'm going to improve it more later .. for now i'm back to JSP ....
You can divide a number by using >> (Bitwise operator) to shift the bits to the right. For example: int i = 10; // 0110 0100 = 100 i >> 1; // 0011 0010 = 50 see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/operator_19.asp Patrick
But u can only divide 'i' by numbers 2^n. i >> n; // 1 / (2 ^n) And for multiplication i << n; // i * 2^n