Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- int a,b;
- char sz[10],*token,op[5];
- while ( gets(sz) )
- {
- token = strtok(sz," ");
- a= atoi(token);
- token = strtok(NULL," ");
- strcpy(op,token);
- token = strtok(NULL," ");
- b= atoi(token);
- if ( a == 0 || b == 0 ) break;
- if ( !strcmp(op,"+") ) printf("%d\n",a+b);
- else if ( !strcmp(op,"/") ) printf("%d\n",a/b);
- else if ( !strcmp(op,"*") ) printf("%d\n",a*b);
- else if ( !strcmp(op,"-") ) printf("%d\n",a-b);
- else if ( !strcmp(op,"%") ) printf("%d\n",a%b);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement