#5699: 請教高手-空格處理


CSE911509 (↙★~柏霖~☆↗)


#include <iostream>
using namespace std;
int main(){
    int x,y,z,b,c;
    char a[10000],B[10000];
    while(gets(a)!=0)
    {
      b=strlen(a);
      z=0;
      for(y=0;y<b;y++)
      {
       if(a[y]>=48 && a[y]<=57)
       c=a[y]-48;
       cout<<c<<endl;
       z+=c;
      }
       cout<<z<<endl;
    }   
  return 0;
}

請教各位高手~ 該如何處理空格的部份呢??

#5709: Re:請教高手-空格處理


k578778 (指標 結構 鏈結 好難...)


#include
using namespace std;
int main(){
    int x,y,z,b,c;
    char a[10000],B[10000];
    while(gets(a)!=0)
    {
      b=strlen(a);
      z=0;
      for(y=0;y      {
       if(a[y]>=48 && a[y]<=57)
       c=a[y]-48;
       cout<       z+=c;
      }
       cout<    }   
  return 0;
}

請教各位高手~ 該如何處理空格的部份呢??


c做完都歸0
#5712: Re:請教高手-空格處理


CSE911509 (↙★~柏霖~☆↗)


#include
using namespace std;
int main(){
    int x,y,z,b,c;
    char a[10000],B[10000];
    while(gets(a)!=0)
    {
      b=strlen(a);
      z=0;
      for(y=0;y      {
       if(a[y]>=48 && a[y]<=57)
       c=a[y]-48;
       cout<       z+=c;
      }
       cout<    }   
  return 0;
}

請教各位高手~ 該如何處理空格的部份呢??


c做完都歸0

謝謝 =))