1 solutions
-
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
Information
- ID
- 16616
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By