Facebook
From Ample Ostrich, 1 Year ago, written in Plain Text.
This paste is a reply to Re: Re: Re: Untitled from Colossal Sloth - go back
Embed
Viewing differences between Re: Re: Re: Untitled and Re: Re: Re: Re: Untitled
#include
#include

int adad(char c ){
        return ((int)c>=(int)'0' && (int)'9'>=(int)c);
}
int tabdil(char c){
        return (int)c - (int)'0';
}

int main()
{
        int x;scanf("%i\n",&x);
        long long jam = 0;
        long long jomle = 1;
        int zarib = 1;
        int tavan = 1;
        while(1){
                char c;scanf("%c",&c);
                if(adad(c)){
                        zarib=tabdil(c);
                        while(1){
                                char r;scanf("%c",&r);
                                if(!adad(r)){
                                        break;
                                }
                                zarib*=10;
                                zarib+=tabdil(r);
                        }
                }
                if(c=='x'){
                        scanf(" ^ %i",&tavan);
                        jomle *= zarib * pow(x,tavan);
                }
                if(c == '+' || c == '-'){
                        jam += jomle;
                        if( c == '-'){
                                
jomle = pow(-1, c == '+');
-1;
                        }
                        else{
                                jomle = 1;
                        }
                        zarib = 1;
                        tavan = 1;
                }
                if(c=='\n'){
                        jam+=jomle;
                        break;
                }
        }
        printf("%lli",jam);
}