[C++ ] 第二次作業一
#include "stdafx.h"
#include "iostream"//可以使用cin&cout
#include "math.h"//可以使用數學函數 如log
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
double number=0;
cin>>number;
cout<<"what you type in is:"<<number<<endl;
//==找出總共有幾位數==
int digits=0;
digits=floor(log10(number)+1);
//floor() 無條件捨去法
//ceil() 無條件進位法
cout<<"the digits of"<<number<<"is"<<digits<<endl;
//==找出位數值==
for(int i=0;i<digits;i++)
{
int tens=1;
for(int j=0;j<i;j++)
{
tens=tens*10;
}
cout<<tens<<endl;
int div=number/tens;
cout<<div%10<<endl;
}
system("pause");
return 0;
}
-
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.183.114
→
10/20 20:07, , 1F
10/20 20:07, 1F
→
10/20 20:34, , 2F
10/20 20:34, 2F
→
10/20 20:37, , 3F
10/20 20:37, 3F
→
10/20 20:41, , 4F
10/20 20:41, 4F
推
10/20 20:52, , 5F
10/20 20:52, 5F
推
10/20 22:32, , 6F
10/20 22:32, 6F
→
10/20 22:36, , 7F
10/20 22:36, 7F
→
10/20 23:31, , 8F
10/20 23:31, 8F
推
10/21 20:44, , 9F
10/21 20:44, 9F
推
10/22 20:08, , 10F
10/22 20:08, 10F
推
10/23 20:07, , 11F
10/23 20:07, 11F
推
10/23 20:14, , 12F
10/23 20:14, 12F
推
10/23 23:38, , 13F
10/23 23:38, 13F
※ 編輯: w86083 來自: 114.36.246.105 (02/25 09:29)