irpg Community

Full Version: การแสดงรูป * โดยใช้ภาษา C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
***********
**********
*********
********
*******
******
*****
****
***
**
*
ใช้คำสั่ง for ซ้อนในการวนลูปแต่ผมทำแบบนี้ไม่ได้อะ มันต้องกลับข้างยังไงเหรอครับช่วยบอกที
XD
for(i=1;i<=10;i++){
for(j=10;j>=i;j--){
คำสั่งโชว์;
}
คำสั่งขึ้นบรรทัดใหม่;
}
ตามนี้เลยขอรับ = v =

#include <stdio.h>
#include <string.h>

main()
{
int i;
for(i=1; i<=11; i++){

int j;
for(j=11; j>=i; j--)
{
printf ("*");
}

printf ("\n");
}
}
[shcode=cpp]
#include <stdio.h>

int main(){
int i,j;
for(i=11;i>=0;i--){
for(j=i;j>0;j--){
printf("*");
}
printf("\n");
}
return 0;
}
[/shcode]