scanf 格式字串中:
scanf
%f
float*
%lf
double*
程式碼中宣告 double num; 卻用 scanf("%f", &num);,導致讀取 4 位元組寫入 8 位元組變數,堆疊資料錯位,輸出亂碼。
double num;
scanf("%f", &num);
同理,printf 印 double 可用 %f(因預設提升為 double),但 scanf 嚴格區分指標大小,務必用 %lf。
printf
double
範例修正:
while (scanf("%lf %d", &x, &exp) == 2)
代碼 `void swap(int x, int y)` 交
新手跟著視頻敲代碼卻不知所以然,電腦卡頓、AS 快捷鍵失效、
需求分析 在 VC++ (MFC/OpenCV) 環境下,顯
在 Android 應用開發中,常見需求是:頁面頂部保留一個