N!末尾0的个数

来源:互联网 发布:ui.multiselect.js 编辑:程序博客网 时间:2024/04/29 10:32
Code:
  1. #include <iostream>   
  2. using namespace std;   
  3. int main(int argc, char *argv[])   
  4. {   
  5.     int n;   
  6.     int total = 0;   
  7.     cin >> n;   
  8.     int temp = n;   
  9.     temp /= 5;   
  10.        
  11.     while(temp)   
  12.     {   
  13.         total += temp;   
  14.         temp /= 5;     
  15.     }   
  16.        
  17.     cout << n << "!末尾0的个数为: " << total << endl;   
  18. }