函数(传指针和传引用)与指针的运用
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
char *str_reverese(char *str,int len)
{
char *start = str;
char *end = str + len -1;
char ch;
if(str!=NULL){
while(start < end){
ch = *start;
*start++ = *end;
*end-- = ch;
}
}
return str;
}
void NumCount(char ch,int &n,int &sum)
{
if(ch >= '0' && ch <= '9'){
sum += (ch - '0') * n;
n = n*10;
}
else n = 1;
}
int main()
{
char str[1105];
while(gets(str))
{
int sum = 0;
int n = 1;
str_reverese(str,strlen(str));
for(int i=0;i<strlen(str);i++){
NumCount(str[i],n,sum);
}
cout << sum << endl;
}
}