C++一道不知道难不难的题,希望得到好的方法
输入一断字符,提取出数字字符 如输入sdsf123rew424ar034
则输出:123,424,034
顺便问一下0和字符末尾自带的/0有什么区别;
// Note:Your choice is C++ IDE #include <iostream> using namespace std; int main() { char choose; int counter; counter=0; cout<<"please input some char.\n"; do { cin.get(choose); //接受空白字符 if(choose>=48&&choose<=57) //判断是数字 counter++; }while(choose!='\n'); cout<<"the all number is\n"<<counter; getchar(); return 0; }: