close
標題:

programming C problem

發問:

#include main( ){printf("%u\n%x\n%X\n%e\n%E\n%f\n%g\n%G\n%c\n%s\n%4d\n%4d\n%.3f\n%.11s\n%10s\n%-10s\n",455,32000,2000000000,455,455,455,455,1234567.89,1234567.89,1234567.89,1234567.89.'a',"this is a string",1,12345,123.94536,"Happy... 顯示更多 #include main( ) { printf("%u\n%x\n%X\n%e\n%E\n%f\n%g\n%G\n%c\n%s\n%4d\n %4d\n%.3f\n%.11s\n%10s\n%-10s\n", 455,32000,2000000000,455,455,455,455,1234567.89,1234567.89,1234567.89,1234567.89.'a',"this is a string",1,12345,123.94536,"Happy Birthday","Hello","Hello"); } 更新: the output is: 455 1c7 1C7 1.234568e+06 1.234568E+06 1234567.890000 1.23457e+0.6 1.23457E+0.6 A This is a string 1 12345 123.945 Happy Birthday Hello Hello 更新 2: 1)why must type after #include? 2)why must place a % before conversion specifier (eg: %d ) 3)can u explain the "%4d" the output is " 1 ", what is the meaning of 4? 4)why there is a . before c.s (eg: %.11s) 5)why there is a - before c.s (eg: %-10s) 更新 3: correction for the command #include main( ) { printf(“%u %x %X %e %E %f %g %G %c %s %4d %4d %.3f %.11s %10s %-10s ”, 455,455,455,455,1234567.89,1234567.89,1234567.89,1234567.89, ‘A’, “This is a string”,1,12345,123.94536,“Happy Birthday”, “Hello” , “Hello”); }

免費註冊體驗

 

此文章來自奇摩知識+如有不便請留言告知

最佳解答:

1)why must type after #include? #include 係header file, 即係依個program 要用咩library 或者其他已起好既 header, 要放係第一行係因為當你要 compile 時, compiler 要嘗試link 返其他header define 左既 function, 如果唔係佢就check 唔到有冇其他地方知該function 有冇被起好 2)why must place a % before conversion specifier (eg: %d ) % 係 reserve word, 主要係比compiler 知道係要print out / read in 一個variable, 而d 係類吃 3)can u explain the "%4d" the output is " 1 ", what is the meaning of 4? %4d 係只小要有4個位 4)why there is a . before c.s (eg: %.11s) %.11s 最多 print 11個位 5)why there is a - before c.s (eg: %-10s) %-10s 各左移10個位 條link 雖然係 C++, 但解釋一樣

其他解答:
arrow
arrow

    oqg08ig24q 發表在 痞客邦 留言(0) 人氣()