ผมทำได้แค่นี้อ่าคับ ส่วนของการแสดงผลมันไม่ถูก หมดปัญญาจิง ๆ อ่าคับ การแสดงผล มันเป็นแบบ bubble อ่าคับ ผมมึนไปหมดแล้ว
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int choice;
int num[]={},a,amount,tmp, i, j;
do{
system("cls");
printf("\tStraight Insertion\n\n");
printf("1.Run Program\n");
printf("0.Exit\n");
printf("\n\nEnter choice : ");
scanf("%d",&choice);
switch(choice){
case 1:
{
system("cls");
printf("Enter Amount Number in List < Min number is 10 > : ");
scanf("%d",&amount);
if(amount >=10)
{
for(a=0;a<amount;a++)
{
printf("Enter number [%d]: ",a+1);
scanf("%d",&num[a]);
}
for(i = 1 ; i < amount ; i++)
{
for(j = i ; j > 0 ; j--)
{
if(num[j] < num[j-1])
{
tmp = num[j];
num[j] = num[j-1];
num[j-1] = tmp;
}else
{
break;
}
}
printf("\nSort [%d] : ",i);
for(j = 0 ; j < amount ; j++)
{
printf(" %d ", num[j]);
}
printf("\n");
}
}
else
{
system("cls");
printf("Amount >= 10\n");
}
break;
}
case 0:
{
break;
}
default :
{
printf("Please select choice\n");
}
}
system("pause");
}while(choice != 0);
system("cls");
printf("End program\n");
system("pause");
return 0;
}
ช่วยเรื่อง Straight Insertion หน่อยคับ
Moderators: mindphp, ผู้ดูแลกระดาน
-
- PHP Newbie
- Posts: 1
- Joined: 14/02/2011 12:56 pm
-
- Similar Topics
- Replies
- Views
- Last post
-
-
ถามเกี่ยวกับสคริป php หน่อยคับ โทษทีถ้าถามผิดห้อง
by youscoms » 23/04/2012 6:49 pm » in Programming - PHP - 4 Replies
- 2484 Views
-
Last post by rangsun6342
16/05/2012 10:24 am
-
-
- 6 Replies
- 2451 Views
-
Last post by VIO
27/08/2011 11:15 am
-
- 1 Replies
- 920 Views
-
Last post by M004
16/05/2013 9:52 am
-
- 3 Replies
- 1204 Views
-
Last post by M027
19/08/2015 4:05 pm
-
-
ถามเรื่องการแสดงผลของ Flask หน่อยคับ มันขึ้น Internal Server Error
by nuattawoot » 16/06/2017 4:08 pm » in Programming - C/C++ & java & Python - 3 Replies
- 528 Views
-
Last post by mindphp
20/06/2017 11:21 am
-
Who is online
Users browsing this forum: No registered users and 6 guests