程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> If We Were a Child Again

If We Were a Child Again

編輯:C++入門知識

If We Were a Child Again


Description

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

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).

Output

A line for each input, each containing an integer. See the sample input and output. Output should not contain any extra space.

Sample Input

110 / 100
99 % 10
2147483647 / 2147483647
2147483646 % 2147483647

Sample Output

1
9
1
2147483646

HINT

#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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved