1 条题解
-
0
C++ :
#include <bits/stdc++.h> using namespace std; string s; int add,ans; int main(){ cin>>s; for(int i=0;i<s.size();i++) { if(s[i]>='0'&&s[i]<='9') add=add*10+s[i]-'0'; if(s[i]=='+'||s[i]=='=') { ans+=add; add=0; } } cout<<s<<ans; return 0; }
Pascal :
var s,t:string; b,g,k,n:longint; begin readln(s); t:=s; repeat b:=b+1; if s[b]='+' then begin g:=pos('+',s); val(copy(s,1,g-1),k); n:=n+k; delete(s,1,g); b:=0; end; if s[b]='=' then begin g:=pos('=',s); val(copy(s,1,g-1),k); n:=n+k; delete(s,1,g); b:=0; end; until s=''; writeln(t,n); end.
- 1
信息
- ID
- 1231
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者