tricky programs that you have encountered ...

Discussion in 'Programming/Html' started by deathvirus, May 2, 2005.

  1. bakuryu

    bakuryu Ancient Guru

    Messages:
    3,270
    Likes Received:
    1
    GPU:
    XFX GeForce 6600LE @ 430/490
    This is only a part of the permutation program.........
    PHP:
    void Permute::permute(int start,int num)
    {
        static 
    int row 0col 0// row number & coloumn number. 
        
    if (num == 1) { // print the word.
            
    if (col == 0) {
                
    cout << "   " << flush;
                
    col += 3;
            }
            
    cout << << "   " << flush;
            
    col += strlen(s)+3;
            if (
    col strlen(s) + 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 026i++)
                
    f[i] = 0;
            for (
    starts[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....
     
    Last edited: Jul 9, 2005
  2. deathvirus

    deathvirus Ancient Guru

    Messages:
    4,507
    Likes Received:
    13
    GPU:
    RTX 2070 MaxQ 8GB
    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 ????
     
  3. deathvirus

    deathvirus Ancient Guru

    Messages:
    4,507
    Likes Received:
    13
    GPU:
    RTX 2070 MaxQ 8GB
    And i still haven't got the previous question .. and its solutions ... be a bit more descriptive on the question please ....
     
  4. bakuryu

    bakuryu Ancient Guru

    Messages:
    3,270
    Likes Received:
    1
    GPU:
    XFX GeForce 6600LE @ 430/490
    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
     

  5. bakuryu

    bakuryu Ancient Guru

    Messages:
    3,270
    Likes Received:
    1
    GPU:
    XFX GeForce 6600LE @ 430/490
    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.......
     
  6. deathvirus

    deathvirus Ancient Guru

    Messages:
    4,507
    Likes Received:
    13
    GPU:
    RTX 2070 MaxQ 8GB
    Thanks for the info ......
     
  7. deathvirus

    deathvirus Ancient Guru

    Messages:
    4,507
    Likes Received:
    13
    GPU:
    RTX 2070 MaxQ 8GB
    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;
        }
        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 ....
     
  8. oxbld

    oxbld Member

    Messages:
    15
    Likes Received:
    0
    GPU:
    XFX Geforce 6800LE 16x6 w/NV Silencer
  9. bakuryu

    bakuryu Ancient Guru

    Messages:
    3,270
    Likes Received:
    1
    GPU:
    XFX GeForce 6600LE @ 430/490

Share This Page