The Problem
The first project for the poor student was to make a calculator that can just perform the basic arithmetic operations.
But like many other university students he doesn’t like to do any project by himself. He just wants to collect programs from here and there. As you are a friend of him, he asks you to write the program. But, you are also intelligent enough to tackle this kind
of people. You agreed to write only the (integer) division and mod (% in C/C++) operations for him.
Input is a sequence of lines. Each line will contain an input number. One or more spaces. A sign (division or mod). Again spaces. And another input number. Both the input numbers are non-negative integer. The first one may be arbitrarily long. The second number n will be in the range (0 < n < 231).
A line for each input, each containing an integer. See the sample input and output. Output should not contain any extra space.
110 / 100
99 % 10
2147483647 / 2147483647
2147483646 % 2147483647
1
9
1
2147483646
#include#include using namespace std; int main() { char str[1000],a[100],b[100],c; int t,i,j,x,y; int num,s,d[1000],e,m; while(gets(str)) { t=0; for(i=0;str[i];i++) { if(str[i]=='/'||str[i]=='%') { c=str[i]; a[t-1]='\0'; break; } else a[t++]=str[i]; } a[t]='\0'; t=0; for(j=i+2;str[j];j++) b[t++]=str[j]; b[t]='\0'; x=strlen(a); y=strlen(b); s=0; if(strcmp(a,b)<0&&x