郑轻oj1065
#include<stdio.h>
#include<string.h>
#include<math.h>
//#include<malloc.h>
//輸入一行字符,以回車符作為輸入結束的標志。統計其中數字字符的個數。
//多個字符,以回車符結束,回車符不作為有效字符。
//輸出一個整數,表示數字字符的個數。int main()
{//思路:簡單點想的話用庫函數strlen(),難點的話就輸入一個記一個數,都可以解決問題char password[50];char *passwordf=password;//指針變量指向數組首地址int longth,cnt=0;//cnt記錄數字個數gets(password);//把輸入的字符串給passwordlongth=strlen(password);//字符串長度for(int i=0;i<longth;i++){if((*passwordf>=48)&&(*passwordf<=57))//ASCII碼 0-9{cnt++;}passwordf++;//指針指向下一個變量地址}printf("%d",cnt);return 0;//今天又是沒帶return 0的一天
}
?
總結
- 上一篇: 钣金加工的工艺流程,根据钣金件结构的差异
- 下一篇: Fresco+retrofit+rxja