?? c03b.cpp
字號:
// c03b.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <iomanip.h>
long numOf5( long n );
int main(int argc, char* argv[])
{
long n;
cout << "請輸入一個正整數(shù):";
cin >> n;
if ( n < 0 )
n = 1;
cout << endl;
long k = 0, k_old = 0;
for ( int j = 1; j <= n; ++j )
{
k_old = k;
int i = 5;
for ( k = 0; i <= j; i +=5 )
k += numOf5( i );
if ( k_old != k )
cout << endl;
cout << setw(5) << j << "! 中末尾0的個數(shù)為 " << setw(5) << k << endl;
}
cout << endl;
return 0;
}
long numOf5( long n )
{
long i = 0;
for ( ; n%5==0; ++i )
n /= 5;
return i;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -