• 1063 弟弟的作业


    // Test1063-弟弟的作业.cpp: 定义控制台应用程序的入口点。
    //
    
    #include "stdafx.h"
    #include <stdlib.h>
    
    
    int main()
    {
        int result = 0;
        while (1)
        {
            char list[12] = {};
            scanf_s("%s", list, 10);
            if (list[1] =='')
                break;
            int middle = 0;
            int sumpos = 0;
            int length = 0;
            int a, b, temp_sum,sum = 0;
    
    
            for (int i = 0;i<10; i++)
            {
                if ((list[i] == '+') || (list[i] == '-'))
                    middle = i;
                if (list[i] == '=')
                    sumpos = i;
                if (list[i] == '')
                    length = i;
            }
            if (list[sumpos + 1] == '?')
                continue;
    
    
            if((middle-0)==2)
            {
                //printf("%d %d ", atoi(&list[0]), atoi(&list[1]));
                //a= atoi(&list[0])*10+atoi(&list[1]);
                a = atoi(&list[0]);
    
            }else
                a= atoi(&list[0]);
    
            if ((sumpos - middle - 1) == 2)
            {
                //b = atoi(&list[middle + 1]) * 10 + atoi(&list[middle+2]);
                b = atoi(&list[middle + 1]);
            }
            else
                b = atoi(&list[middle + 1]);
    
            if ((length - sumpos - 1) == 3)
                //sum = atoi(&list[sumpos + 1]) * 100 + atoi(&list[sumpos + 2]) * 10 + atoi(&list[sumpos + 3]);
                sum = atoi(&list[sumpos + 1]);
            else if ((length - sumpos - 1) == 2)
                //sum = atoi(&list[sumpos + 1]) * 10 + atoi(&list[sumpos + 2]);
                sum = atoi(&list[sumpos + 1]);
            else
                sum = atoi(&list[sumpos + 1]);
    
    
    
            if (list[middle] == '+')
                temp_sum = a + b;
            if (list[middle] == '-')
                temp_sum = a - b;
            if  (temp_sum== sum)
                result++;
            printf("%s
    ", list);
    
    
        }
        printf("%d
    ", result);
    
    
    
        //while ((c = getchar()) != EOF)
        //{
        //    putchar(c);
        //}
    
        return 0;
    }
    1 1+2=3
    2 3-1=5
    3 6+7=13
    4 99-0=5 99-0=99
    6 0
    7 3
    8 请按任意键继续. . .

    万事走心 精益求美


  • 相关阅读:
    测试爬虫
    流式大数据处理的三种框架:Storm,Spark和Samza
    redo日志
    HTTP协议之chunk编码(分块传输编码
    QWidget 实现 打破布局 或者 当前窗体内的 弹窗 (借助伪造实现)
    How to use kingshard building a MySQL cluster
    转载: Qt 学习之路 2归档
    Python与机器人技术
    Nginx配置正向代理
    使用Chrony配置 NTP
  • 原文地址:https://www.cnblogs.com/kongchung/p/9330629.html
Copyright © 2020-2023  润新知