統計個位數字 15 分

2021-10-22 13:12:40 字數 431 閱讀 5636

統計個位數字 (15 分)

本題要求實現乙個函式,可統計任一整數中某個位數出現的次數。例如-21252中,2出現了3次,則該函式應該返回3。

函式介面定義:

int count_digit ( const int n, const int d );

其中n和d都是使用者傳入的引數。n的值不超過int的範圍;d是[0, 9]區間內的個位數。函式須返回n中d出現的次數。

裁判測試程式樣例:

#include

int count_digit ( const int n, const int d );

int main()

else

if(n<0)

else

while

(s!=0)

s=s/10;

}return t;

}

4 9 統計個位數字 15分

本題要求實現乙個函式,可統計任一整數中某個位數出現的次數。例如 21252中,2出現了3次,則該函式應該返回3。函式介面定義 int count digit const int n,const int d 其中n和d都是使用者傳入的引數。n的值不超過int的範圍 d是 0,9 區間內的個位數。函式須...

4 9 統計個位數字 15分

本題要求實現乙個函式,可統計任一整數中某個位數出現的次數。例如 21252中,2出現了3次,則該函式應該返回3。int count digit const int n,const int d 其中n和d都是使用者傳入的引數。n的值不超過int的範圍 d是 0,9 區間內的個位數。函式須返回n中d出現...

6 9 統計個位數字(15 分)

本題要求實現乙個函式,可統計任一整數中某個位數出現的次數。例如 21252中,2出現了3次,則該函式應該返回3。int count digit const int n,const int d 其中n和d都是使用者傳入的引數。n的值不超過int的範圍 d是 0,9 區間內的個位數。函式須返回n中d出現...