C Constructs for Iteration - for Loops ContinuedThere are some shortcu การแปล - C Constructs for Iteration - for Loops ContinuedThere are some shortcu ไทย วิธีการพูด

C Constructs for Iteration - for Lo

C Constructs for Iteration - for Loops Continued
There are some shortcut ways to write the increment/decrement expression:
/* The following incrementing expressions are equivalent */
i = i + 1;
i += 1;
i++; /* this is one used most often in loops */
/* The following decrementing expressions are equivalent */
j = j - 1;
j -= 1;
j--;
What about ++j;?
Prefixing the increment or decrement operator means that the program will add (or substract) 1 before it does any calculation with or testing of the value. Sometimes this is what you want. Sometimes it does not make any difference. See the demo prePostIncrement.c.
You don’t have to add or subtract 1 - you can use any value:
/* The following loop prints all multiples of 5
* between zero and one hundred, inclusive.
*/
for (num = 0; num
0/5000
จาก: -
เป็น: -
ผลลัพธ์ (ไทย) 1: [สำเนา]
คัดลอก!
C สร้างสำหรับการเกิดซ้ำ - สำหรับต่อลูป
มีบางวิธีลัดในการเขียนนิพจน์ เพิ่ม/decrement:
/ * incrementing นิพจน์ต่อไปนี้จะเทียบเท่า * /
ฉัน = 1 ฉัน
ฉัน = 1;
ฉัน / * นี้เป็นหนึ่งมักใช้ในลูป * /
/ * decrementing นิพจน์ต่อไปนี้จะเทียบเท่า * /
เจ = j - 1;
เจ-= 1;
j-;
อะไร j;
ใส่คำเสริมหน้าจะเพิ่มขึ้น หรือ decrement ตัวหมายความว่าโปรแกรมจะเพิ่ม (หรือลบตัว) 1 ก่อนมันไม่มีคำนวณด้วยหรือการทดสอบค่า บางครั้งนี่คือสิ่งที่คุณต้อง บางครั้งก็ไม่สามารถทำให้ความแตกต่าง ดู prePostIncrement.c.
You สาธิตไม่มีการบวก หรือลบ 1 - คุณสามารถใช้ค่าใด ๆ:
/ * วนต่อไปนี้พิมพ์ทั้งหมดคูณ 5
* ระหว่างศูนย์และหนึ่งร้อย รวม.
* /
สำหรับ (num = 0; num < = 100; num = num 5)
{
printf ("%d
", num);
}
เงื่อนไขการทดสอบมักจะตรวจสอบค่าของตัวแปรวนกับขีดจำกัดบางอย่าง อย่างไรก็ตาม อาจเป็นนิพจน์ที่ซับซ้อนการเพิ่มนิพจน์เช่น:
/ * พิมพ์ค่าไบนารีของเลขทศนิยมทั้งหมดจาก
* 0-100 จนกว่าผู้ใช้บอกให้คุณหยุดได้
* /
ค่า int;
อักขระตอบ [8];
int bStop = 0;
สำหรับ (ค่า = 0 (ค่า < = 100) && (bStop == 0); ค่า)
{
printf ("%d ในไบนารีคือ %s
", convertToBinaryString(value)) ค่า
printf ("คุณต้องการหยุดหรือไม่ (Y/N) ");
fgets(response,sizeof(response),stdin);
ถ้า (ตอบ [0] == 'Y')
bStop = 1 }
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 2:[สำเนา]
คัดลอก!
C Constructs for Iteration - for Loops Continued
There are some shortcut ways to write the increment/decrement expression:
/* The following incrementing expressions are equivalent */
i = i + 1;
i += 1;
i++; /* this is one used most often in loops */
/* The following decrementing expressions are equivalent */
j = j - 1;
j -= 1;
j--;
What about ++j;?
Prefixing the increment or decrement operator means that the program will add (or substract) 1 before it does any calculation with or testing of the value. Sometimes this is what you want. Sometimes it does not make any difference. See the demo prePostIncrement.c.
You don’t have to add or subtract 1 - you can use any value:
/* The following loop prints all multiples of 5
* between zero and one hundred, inclusive.
*/
for (num = 0; num <= 100; num = num + 5)
{
printf("%d
", num);
}
The test condition will usually check the value of the loop variable against some limit. However, it can be a compound expression that tests additional expressions as well:
/* print the binary values of all decimal numbers from
* 0 to 100 unless the user tells you to stop.
*/
int value;
char response[8];
int bStop = 0;
for (value = 0; (value <= 100) && (bStop == 0); value++)
{
printf("%d in binary is %s
", value, convertToBinaryString(value));
printf("Do you want to stop? (Y/N)");
fgets(response,sizeof(response),stdin);
if (response[0] == ’Y’)
bStop = 1; }
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 3:[สำเนา]
คัดลอก!
สำหรับการสร้าง C -
ลูปยังคงมีบางวิธีลัดที่จะเขียนเพิ่ม / ลดการแสดงออก :
/ * ต่อไปนี้ incrementing นิพจน์เทียบเท่า * /
= ผม 1 ;
i = 1 ;
i ; / * นี้เป็นหนึ่งที่ใช้บ่อยที่สุดในลูป * /
/ * ต่อไปนี้ decrementing นิพจน์เทียบเท่า * /
J = 1 J - J ;
-
-- = 1 ; J ;
แล้ว J ; ?
prefixing เพิ่มขึ้นหรือลดลงผู้ประกอบการหมายความว่าโปรแกรมจะเพิ่ม ( หรือลบ ) ก่อนที่มันจะมีการคำนวณด้วยหรือทดสอบค่า บางครั้งนี้เป็นสิ่งที่คุณต้องการ บางครั้งมันไม่ได้สร้างความแตกต่างใด ๆ ดูการสาธิต prepostincrement . C .
คุณไม่ต้องเพิ่มหรือลบ 1 - คุณสามารถใช้ค่าใด ๆ :
/ * ต่อไปนี้ทั้งหมดคูณ 5
วงพิมพ์* ระหว่างศูนย์และหนึ่งร้อย รวม
/
( num = 0 ; Num < = 100 ; num num = 5 ) {

printf ( " %d n " , สี ) ;
}
เงื่อนไขการทดสอบจะตรวจสอบค่าของตัวแปร ห่วง กับ จำกัด อย่างไรก็ตาม จะเป็นสารประกอบที่แสดงออกแบบสำนวนเพิ่มเติมเช่นกัน :
/ * พิมพ์ค่าของตัวเลขทศนิยมไบนารีทั้งหมดจาก
0 ถึง 100 ถ้าผู้ใช้บอกคุณ

* / หยุดค่า int ;
ตอบสนอง char [ 8 ] ;
1 bstop = 0 ;
( ค่า = 0 ; ( ค่า < = 100 ) && ( bstop = = 0 ) { ; ค่า )

printf ( " %d ในไบนารีคือ %s n " ค่า converttobinarystring ( ค่า ) )
printf ( " คุณต้องการที่จะหยุด ( y / n ) " ) ;
fgets ( การตอบสนอง , มี ( การตอบสนอง ) เช่น stdin ) ;
( ถ้าการตอบสนอง [ 0 ] = = ' Y ' )
bstop = 1 ; }
การแปล กรุณารอสักครู่..
 
ภาษาอื่น ๆ
การสนับสนุนเครื่องมือแปลภาษา: กรีก, กันนาดา, กาลิเชียน, คลิงออน, คอร์สิกา, คาซัค, คาตาลัน, คินยารวันดา, คีร์กิซ, คุชราต, จอร์เจีย, จีน, จีนดั้งเดิม, ชวา, ชิเชวา, ซามัว, ซีบัวโน, ซุนดา, ซูลู, ญี่ปุ่น, ดัตช์, ตรวจหาภาษา, ตุรกี, ทมิฬ, ทาจิก, ทาทาร์, นอร์เวย์, บอสเนีย, บัลแกเรีย, บาสก์, ปัญจาป, ฝรั่งเศส, พาชตู, ฟริเชียน, ฟินแลนด์, ฟิลิปปินส์, ภาษาอินโดนีเซี, มองโกเลีย, มัลทีส, มาซีโดเนีย, มาราฐี, มาลากาซี, มาลายาลัม, มาเลย์, ม้ง, ยิดดิช, ยูเครน, รัสเซีย, ละติน, ลักเซมเบิร์ก, ลัตเวีย, ลาว, ลิทัวเนีย, สวาฮิลี, สวีเดน, สิงหล, สินธี, สเปน, สโลวัก, สโลวีเนีย, อังกฤษ, อัมฮาริก, อาร์เซอร์ไบจัน, อาร์เมเนีย, อาหรับ, อิกโบ, อิตาลี, อุยกูร์, อุสเบกิสถาน, อูรดู, ฮังการี, ฮัวซา, ฮาวาย, ฮินดี, ฮีบรู, เกลิกสกอต, เกาหลี, เขมร, เคิร์ด, เช็ก, เซอร์เบียน, เซโซโท, เดนมาร์ก, เตลูกู, เติร์กเมน, เนปาล, เบงกอล, เบลารุส, เปอร์เซีย, เมารี, เมียนมา (พม่า), เยอรมัน, เวลส์, เวียดนาม, เอสเปอแรนโต, เอสโทเนีย, เฮติครีโอล, แอฟริกา, แอลเบเนีย, โคซา, โครเอเชีย, โชนา, โซมาลี, โปรตุเกส, โปแลนด์, โยรูบา, โรมาเนีย, โอเดีย (โอริยา), ไทย, ไอซ์แลนด์, ไอร์แลนด์, การแปลภาษา.

Copyright ©2024 I Love Translation. All reserved.

E-mail: