integerstringsum

All submissions for this problem are available.
Tom and Bob are good friends.Tom is fond of solving problems.Bob gave a problem to Tom.He gave him a string of numbers and alphabets.He wants Tom to find the sum of all integers that occurs in the given string . As Tom is a bad programmer he needs your help to solve this problem.
Input
 The first line contains T i.e. the number of test cases.
.  T lines follow, each line containing a string,
Output
 For each testcase, output a single line containing the sum of integers that occure in string
Constraints
 1 ≤ T ≤ 10^9
 1 ≤ s ≤ 10^5
Example
Input: 1 abc12def4gh Output: 16
Solution
#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t) { string a; cin>>a; long long int i,j,k=0,l,b[100000],c[100000],n,m; n=a.size(); k=n1; for(i=0;i<n;i++) { if('0'<=a[i] && a[i]< '9') { b[k]=int(a[i]) int('0'); } else { for(j=k;j<n;j++) { c[m]+=b[j]; b[j]=0; if(c[m]>9) { c[m+1]+=1; c[m]%=10; } m+=1; } k=n1; m=0; } } m=0; for(j=k;j<n;j++) { c[m]+=b[j]; b[j]=0; if(c[m]>9) { c[m+1]+=1; c[m]%=10; } m+=1; } k=1; for(i=n1;i>0;i) { if(c[i]!=0 ) { k=i; break; } } if(k=1) cout<<"1"; else { for(i=k1;i>0;i) cout<<c[i]; } cout<<endl; } return 0; }
Steps to be followed
1. Read the given description carefully and understand the problem.
2. Analyze the code given in the problem and find bugs(errors) in these codes..
3. The given code can be copied and compiled in an online compiler (Eg. ideone.com).
4. Once the bugs are eliminated from the code, the clean code can be submitted as the solution to the problem..
5. The solution should be a debugged version of the code provided and must satisfy the test cases to be accepted..
All the best!!
Author:  vipinkhushu 
Editorial  http://discuss.codechef.com/problems/FEST06 
Tags  vipinkhushu 
Date Added:  9032016 
Time Limit:  1  20 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, PYTH, PYTH 3.6, PYPY, PYP3 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 