ดูหน้านี้ใน รูปแบบเต็ม
ทำ text formatting ไม่ได้ค่ะ
printf("%d\n", 1668);
printf("%g\n", 1668.258);
printf("%.3f\n", 1668.258);
printf("%.3f\n", "1668.258");
printf("%+d\n", 422);
printf("%04d\n",422);
printf("%.2f\n", M_PI); // ค่าคงที่ M_PI = 3.141593...
printf("%s\n", "I\'m eager to go to the next page");
ทำไปแบบนี้อ่คะ มันผิดตรงไหนบ้างหรอค่ะ ช่วยบอกหน่อยนะคะ ขอบคุนมากๆค่ะ
โดย [F][a][H] เมื่อ 28 Sep 2551 11:28:54
หน้า 1 จาก 1
«1»
#1 โดย ping128 เมื่อ 28 Sep 2551 12:08:21Code (C++)
#include<stdio.h>
#include<math.h>
int main(void){
printf("%d\n", 1668);
printf("%g\n", 1668.258);
printf("%.3f\n", 1668.258);
printf("%.3f\n", "1668.258");
printf("%+d\n", 422);
printf("%04d\n",422);
printf("%.2f\n", M_PI);
printf("%s\n", "I\'m eager to go to the next page");
return 0;
}
ต้องพิมพ์เป็น โปรเเกรมเลยครับ
#2 โดย [F][a][H] เมื่อ 28 Sep 2551 15:59:20ทำแบบนั้นไปแล้วค่ะ แต่มันยังไม่ให้ผ่านไปหน้าอื่นค่ะ
ทำยังไงดีค๊ะ???
#3 โดย ping128 เมื่อ 28 Sep 2551 16:46:20
printf("%d\n", 1668);
printf("%.2f\n", 1668.258);
printf("%.3f\n", 1668.258);
printf("%s\n", "1668.258");
printf("%+d\n", 422);
printf("%04d\n", 422);
printf("%.2f\n", M_PI); printf("%s\n", "I\'m eager to go to the next page");
ลองดูใหม่นะครับ
#4 โดย booky เมื่อ 6 Jan 2552 16:02:40เลขเยอะเกินอะ
#5 โดย nooduan eh oh~ เมื่อ 8 Jan 2552 10:30:20อะริกาโตโงะไซมัส
#6 โดย nooduan eh oh~ เมื่อ 8 Jan 2552 10:43:36คัดซัมนิดา~
#7 โดย shitokung เมื่อ 10 Dec 2554 15:52:42ติดเหมือนกัน ผิดบรรทัดนี้เอง
printf("%s\n", "1668.258");
#8 โดย kaara17 เมื่อ 1 Feb 2555 21:34:41printf("%s\n", "1668.258"); ทำไมต้องใช้ %S ด้วยช่วยอธิบายให้หน่อยนะครับ ขอบคุณมากครับ
#9 โดย Eversong เมื่อ 16 Feb 2555 13:08:58เพราะเป็น string ครับ ไม่ใช่เลข สังเกตุจาก "
#10 โดย samos เมื่อ 22 Mar 2555 15:34:34ขอบคุณมากครับ