2016 Pacific Northwest Region Programming Contest—Division 2 Problem R — limit 1 second Equality


Problem R — limit 1 second Equality
You are grading an arithmetic quiz. The quiz asks a student for the sum of the numbers. Determine if the student taking the quiz got the question correct.
Input
The first and the only line of input contains a string of the form:
a + b = c
It is guaranteed that a, b, and c are single-digit positive integers. The input line will have exactly 9 characters, formatted exactly as shown, with a single space separating each number and arithmetic operator.
Output
Print, on a single line, YES if the sum is correct; otherwise, print NO.
Sample Input Sample Output
1 + 2 = 3 YES
Sample Input Sample Output
2 + 2 = 5 NO
2016 Pacific Northwest Region Programming Contest—Division 2











#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
 char s[10]; 
 gets(s);
 int a = atoi(&s[0]);
 int b = atoi(&s[4]);
 int c = atoi(&s[8]);
 if(a + b == c)
  printf("YES\n");
 else
  printf("NO\n");
 //printf("%c %c %c",s[0],s[4],s[8]);
 return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值