F - Addition and Subtraction Easy

该博客主要讲述了如何处理A和B之间的加减法运算,其中A和B是不超过10^9的整数,运算符可能是加号或减号。内容强调了解决输入问题的关键,通过使用无关变量m和n来处理空格。任务是帮助Joisino求解给定的数学公式并打印结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

注意一下输入,当时尝试了很多办法才解决的,我用了无关变量m和n存储空格

Problem Statement

Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either + or -. Your task is to evaluate the formula instead of her.

Constraints

  • 1≦A,B≦109
  • op is either + or -.
Input

The input is given from Standard Input in the following format:

A op B
Output

Evaluate the formula and print the result.

Sample Input 1

1 + 2
Sample Output 1

3

Since 1+2=3, the output should be 3.

Sample Input 2

5 - 7
Sample Output 2

-2


#include<cstdio>
int main()
{
	int a,c;
	char b,n,m;
	int sum;
	while(scanf("%d",&a)!=EOF)
	{
		scanf("%c",&m);
		scanf("%c",&b);
		scanf("%c",&n);
		scanf("%d",&c);
		if(b==43)
		{
			sum=a+c;
			printf("%d\n",sum);
		}
		else
		{
			sum=a-c;
			printf("%d\n",sum);
		}

	}
	return  0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值