1. 程式人生 > >《CCF中學生計算機程序設計-入門篇》_例5.23

《CCF中學生計算機程序設計-入門篇》_例5.23

NOIP 信息學奧賽 C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
char s[5];
int x=0,y=0,n=0;

while((s[n]=getchar())!=‘+‘)
{
    x=x*10+s[n]-‘0‘;
    n++;
}
while((s[n]=getchar())!=‘\n‘)
{
    y=y*10+s[n]-‘0‘;
    n++;
}
cout<<x+y;
return 0;

}

《CCF中學生計算機程序設計-入門篇》_例5.23