Linux.com

poonam.gaigole

poonam.gaigole

  • Linux.com Member
  • Posts: 7
  • Member Since: 17 May 10
  • Last Logged In: 14 Apr 11

Latest Posts

Posted by
Topic
Post Preview
Posted
  • poonam.gaigole
    Runtime error in my code...
    INFIX TO POSTFIX CONVERSION : [code][/code] #include #include #include using namespace std; char ifx[50],pfx[50],stk[50]; int top=-1,n; void push(char ch) { if(top!=n-1) { top++; stk[top]=ch; } else cout<<"\nThe stack is full."; } char pop() { char rmv; if(top!=-1) { rmv=stk[top]; top--; return rmv; } else return '#'; } char topele() { char ch; if(top==-1) { ch='#'; return ch; } else ch=stk[top]; } int chkpres(char ch) { ch=topele(); switch(ch) { case '^':return 7; break; case '/':return 6; break; case '*':return 5; break; case '+':return 4; break; case '-':return 3; break; default:return 0; break; } } /*int braces(char *s) { int lftbr,rgtbr=0; for(int i=0;s[i];++i) { if(s[i]=='(') lftbr++; else rgtbr++; } if(lftbr==rgtbr) return 0; else if(lftbr>n; cout<<"\nEnter the infix expression: "; for(int i=0;i>ifx[i]; topp=topele(); strcpy(pfx," "); for(int i=0,j=0;ifx[i]!='\0',pfx[j]!='\0';++i,++j) { ele=ifx[i]; if(ele!='^' && ele!='*' && ele!='/' && ele!='+' && ele!='-') pfx[j++]=ifx[i]; else if(ele=='^'||ele=='*'||ele=='/'||ele=='+'||ele=='-') { if(topp=='^'||topp=='*'||topp=='/'||topp=='+'||topp=='-') { pre=chkpres(ele); pres=chkpres(topp); if(pre>pres) { push(pre); top++; } else if(pre<=pres) pfx[j++]=pres; } else { push(ele); topp=ele; } } else if(ele=='(') { i++; } else if(ele==')') { while(topp!='#') { popp=topp; pfx[i]=popp; } } cout<<"---------------"<
    Link to this post 15 Apr 11

    INFIX TO POSTFIX CONVERSION :


    #include<iostream>
    #include<cstring>
    #include<cstdlib>
    using namespace std;
    char ifx[50],pfx[50],stk[50];
    int top=-1,n;
    void push(char ch)
    {
    if(top!=n-1)
    {
    top++;
    stk[top]=ch;
    }
    else
    cout<<"\nThe stack is full.";
    }
    char pop()
    {
    char rmv;
    if(top!=-1)
    {
    rmv=stk[top];
    top--;
    return rmv;
    }
    else
    return '#';
    }
    char topele()
    {
    char ch;
    if(top==-1)
    {
    ch='#';
    return ch;
    }
    else
    ch=stk[top];
    }
    int chkpres(char ch)
    {
    ch=topele();
    switch(ch)
    {
    case '^':return 7;
    break;
    case '/':return 6;
    break;
    case '*':return 5;
    break;
    case '+':return 4;
    break;
    case '-':return 3;
    break;
    default:return 0;
    break;
    }
    }
    /*int braces(char *s)
    {
    int lftbr,rgtbr=0;
    for(int i=0;s;++i)
    {
    if(s=='(')
    lftbr++;
    else
    rgtbr++;
    }
    if(lftbr==rgtbr)
    return 0;
    else if(lftbr<rgtbr)
    return 1;
    else return -1;
    }*/
    int main()
    {
    char ele,elem,chk,popp,topp;
    int pre,pres;
    cout<<"\nEnter how many elements you want to enter in the infix expression: ";
    cin>>n;
    cout<<"\nEnter the infix expression: ";
    for(int i=0;i<n;++i)
    cin>>ifx;
    topp=topele();
    strcpy(pfx," ");
    for(int i=0,j=0;ifx!='\0',pfx[j]!='\0';++i,++j)
    {
    ele=ifx;
    if(ele!='^' && ele!='*' && ele!='/' && ele!='+' && ele!='-')
    pfx[j++]=ifx;
    else if(ele=='^'||ele=='*'||ele=='/'||ele=='+'||ele=='-')
    {
    if(topp=='^'||topp=='*'||topp=='/'||topp=='+'||topp=='-')
    {
    pre=chkpres(ele);
    pres=chkpres(topp);
    if(pre>pres)
    {
    push(pre);
    top++;
    }
    else if(pre<=pres)
    pfx[j++]=pres;
    }
    else
    {
    push(ele);
    topp=ele;
    }
    }
    else if(ele=='(')
    {
    i++;
    }
    else if(ele==')')
    {
    while(topp!='#')
    {
    popp=topp;
    pfx=popp;
    }
    }
    cout<<"---------------"<<pfx[j++];
    }
    cout<<"\nThe postfix expression is: ";
    for(int i=0;pfx!='\0';++i)
    {
    cout<<pfx;
    }
    cout<<endl;
    return 0;
    }

  • poonam.gaigole
    RE: HELP... error in my simple binary search program
    Well, thank you!
    Link to this post 05 Apr 11

    Well, thank you!

  • poonam.gaigole
    HELP... error in my simple binary search program
    Could any help me with a runtime error in my program? In the program of binary search, I am not getting output if I choose my searching element more than the middle element. Could anyone please help me to debug it? [code][/code] #include using namespace std; int main() { int a[100],n,ele,mid,pos=0; cout<<"\nEnter the number of elements you want to enter in an array: "; cin>>n; cout<<"\nEnter the array: "; for(int i=0;i>a[i]; cout<<"\nEnter the element you want to search: "; cin>>ele; int low=0,high=n-1; while(low<=high) { mid=low+high/2; if(ele==a[mid]) { pos=mid+1; break; } else if(ele
    Link to this post 03 Apr 11

    Could any help me with a runtime error in my program?

    In the program of binary search, I am not getting output if I choose my searching element more than the middle element.
    Could anyone please help me to debug it?


    #include<iostream>
    using namespace std;
    int main()
    {
    int a[100],n,ele,mid,pos=0;
    cout<<"\nEnter the number of elements you want to enter in an array: ";
    cin>>n;
    cout<<"\nEnter the array: ";
    for(int i=0;i<n;++i)
    cin>>a;
    cout<<"\nEnter the element you want to search: ";
    cin>>ele;
    int low=0,high=n-1;
    while(low<=high)
    {
    mid=low+high/2;
    if(ele==a[mid])
    {
    pos=mid+1;
    break;
    }
    else if(ele<a[mid])
    high=mid-1;
    else
    low=mid+1;
    }
    if(pos!=0)
    cout<<"\nThe element you searched is "<<a[mid]<<" and is at position "<<pos<<endl;
    else
    cout<<"\nThe element you were trying to search was not found !"<<endl;
    return 0;
    }

  • poonam.gaigole
    RE: Download youtube videos through the terminal
    I sorry i bothered you so much ... At the time i posted this question the youtube in our network was working but now it's not. When it was working i tried and came to see the error. But I'm really sorry i cannot check it out now. Because the youtube is blocked again in our network. So I cannot say you whether the command youtube-dl -v is really working or not. If youtube again works in our network then I assure you to inform you at once. And well... thank you for your reply
    Link to this post 04 Mar 11

    I sorry i bothered you so much ... At the time i posted this question the youtube in our network was working but now it's not. When it was working i tried and came to see the error. But I'm really sorry i cannot check it out now. Because the youtube is blocked again in our network. So I cannot say you whether the command youtube-dl -v is really working or not. If youtube again works in our network then I assure you to inform you at once.
    And well... thank you for your reply

  • poonam.gaigole
    RE: Download youtube videos through the terminal
    Moreover my adobe flash player is not working because ... I think its because i tried the command in the terminal : sudo apt-get update this tries to get new updates for my ubuntu 10.10 but even though i'm trying a lot to install the new adobe flash player 10 but it's not working. Can you suggest any command that I can type in the terminal to get the adobe flash player 10 through the terminal. Because the terminal is more effective than the "synaptic package manager" or " ubuntu software center" applications... i think so...
    Link to this post 02 Mar 11

    Moreover my adobe flash player is not working because ...
    I think its because i tried the command in the terminal :

    sudo apt-get update

    this tries to get new updates for my ubuntu 10.10 but even though i'm trying a lot to install the new adobe flash player 10 but it's not working. Can you suggest any command that I can type in the terminal to get the adobe flash player 10 through the terminal. Because the terminal is more effective than the "synaptic package manager" or " ubuntu software center" applications... i think so...

  • poonam.gaigole
    RE: Download youtube videos through the terminal
    You can take any URL of the youtube channel. Suppose for example: http://www.youtube.com/watch?v=_QqT38QRA84
    Link to this post 02 Mar 11

    You can take any URL of the youtube channel. Suppose for example:
    http://www.youtube.com/watch?v=_QqT38QRA84

  • poonam.gaigole
    Download youtube videos through the terminal
    I tried the following command in the ubuntu for downloading the youtube videos: youtube-dl "URL" or if we want to specify the file extension : youtube-dl -o filename.flv "URL" This being the most recommended command, doesn't work. It says format is not supported. Moreover I again tried the command : wget -c "URL" But this command also doesn't work . Can anyone help me with this problem???
    Link to this post 02 Mar 11

    I tried the following command in the ubuntu for downloading the youtube videos:

    youtube-dl "URL"

    or if we want to specify the file extension :

    youtube-dl -o filename.flv "URL"

    This being the most recommended command, doesn't work. It says format is not supported.
    Moreover I again tried the command :

    wget -c "URL"

    But this command also doesn't work . Can anyone help me with this problem???

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board