看板 NTUBIME102HW 關於我們 聯絡資訊
#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
w86083:不完整 請大家仔細思考使用 10/20 20:07
ck940560:visual C++在宣告變數時會自動設為0 所以可以不用加=0 10/20 20:34
sb0917:可是是個好習慣... 10/20 20:37
ck940560:神人出現了... 我不用DEV C++所以沒影響-.- 10/20 20:41
flysky46:你騙人 10/20 20:52
ceorl:方法跟我的不一樣說。~。 10/20 22:32
w86083:這是助教上課打的一些資料拉=ˇ= 10/20 22:36
flysky46:所以助教騙人XD 10/20 23:31
lldavuull:太好了 真是救星!!!!!!!!!!!!!!!!!!!!!!! 我都不會寫@@ 10/21 20:44
lostmyself:樓樓上... 我哪有騙人 =_= 10/22 20:08
a1598742002:這是助教出現的意思嘛??????(驚) 丙醇危險了 10/23 20:07
sb0917:助教人超nice的 10/23 20:14
flysky46:ㄎㄎ 助教出現了 我猛慘 果然不能亂說話阿 10/23 23:38
※ 編輯: w86083 來自: 114.36.246.105 (02/25 09:29)