• 1001. A+B Format


    C++语言: Codee#25842
    01 /*
    02 +++++++++++++++++++++++++++++++++++++++
    03                 author: chm
    04 +++++++++++++++++++++++++++++++++++++++
    05 */
    06
    07 #include <map>
    08 #include <set>
    09 #include <list>
    10 #include <queue>
    11 #include <cmath>
    12 #include <stack>
    13 #include <bitset>
    14 #include <cstdio>
    15 #include <cctype>
    16 #include <string>
    17 #include <vector>
    18 #include <cassert>
    19 #include <cstdlib>
    20 #include <cstring>
    21 #include <fstream>
    22 #include <sstream>
    23 #include <iomanip>
    24 #include <iostream>
    25 #include <algorithm>
    26
    27 using namespace std;
    28
    29 FILE*            fin         = stdin;
    30 FILE*            fout         = stdout;
    31 const int        max_size     = 10086;
    32 #define ONLINE_JUDGE
    33 int main()
    34 {
    35 #ifndef ONLINE_JUDGE
    36     freopen("d:\\in.txt", "r", stdin);
    37     freopen("d:\\out.txt", "w", stdout);
    38 #endif
    39     int a, b;
    40     int sum;
    41     int isneg = 0;
    42     char str[max_size];
    43     char ans[max_size];
    44
    45     while(cin >> a >> b)
    46     {
    47         isneg = 0;
    48         if((sum = a + b) < 0)
    49         {
    50             sum *= -1;
    51             isneg = 1;
    52         }
    53         sprintf(str, "%d", sum);
    54         int idx = 0;
    55         if(isneg)
    56             cout << '-';
    57
    58         for(int i = strlen(str), j = 1; j<=i;++j)
    59         {
    60             cout << str[j - 1];
    61             if((i - j) % 3 == 0 && i - j != 0)
    62                 cout << ',';
    63         }
    64         cout << endl;
    65     }
    66
    67 #ifndef ONLINE_JUDGE
    68     fclose(stdout);
    69     system("start d:\\check.exe d:\\out.txt d:\\ans.txt");
    70 #endif
    71     return 0;
    72 }
  • 相关阅读:
    前端神器avalonJS入门(一)
    emmet的使用
    VS2015中SharedProject与可移植类库(PCL)项目
    Map工具系列-08-map控件查看器
    Map工具系列-07-TFS变更集提取工具
    Map工具系列-06-销售营改增历史数据处理工具
    2018.04.02 matplotlib 图名,图例,轴标签,轴边界,轴刻度,轴刻度标签
    2018.03.30 abap屏幕标签保存之前执行过的状态
    2018.03.29 python-matplotlib 图表生成
    2018.03.29 python-pandas 数据读取
  • 原文地址:https://www.cnblogs.com/invisible/p/2400337.html
Copyright © 2020-2023  润新知