码迷,mamicode.com
首页 > 其他好文 > 详细

问题 1073: 弟弟的作业

时间:2017-06-29 23:53:35      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:amp   ring   blog   ber   正确答案   count   cst   auth   html   

/********************************************************************
@file     Main.cpp
@date     2017-5-8
@author   Zoro_Tiger
@brief    问题 1073: 弟弟的作业
          http://www.dotcpp.com/oj/problem1073.html
********************************************************************/
//!头文件
#include <cstdio>
#include <string>

//!程序入口
int main(int argc, const char* argv[])
{
    //!变量声明
    int right_answer_count = 0, number_a, number_b, number_c, number_result;
    char oper;
    std::string result;

    //!统计正确答案个数
    while (scanf("%d%c%d=%s", &number_a, &oper, &number_b, result.c_str()) != EOF)
    {
        number_c = (oper == + ? number_a + number_b : number_a - number_b);
        if (result != "?")
        {
            number_result = atoi(result.c_str());
            if (number_result == number_c)
            {
                ++right_answer_count;
            }
        }
    }

    //!显示结果
    printf("%d\n", right_answer_count);

    //!返回系统
    return 0;
}

 

问题 1073: 弟弟的作业

标签:amp   ring   blog   ber   正确答案   count   cst   auth   html   

原文地址:http://www.cnblogs.com/roronoa-zoro-zrh/p/7096707.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!