?? 12-5b.txt
字號:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUM 100
int main(void)
{
int i ,top ,current ,temp;
int randnum[NUM];
srand(time(0));
for (i = 0; i < NUM; i++)
randnum[i] = rand() % 10 + 1;
puts("Before sort:");
for (i = 0; i < NUM; i++)
{
printf("%2d ", randnum[i]);
if (i % 10 == 9)
putchar('\n');
}
if (i % 10 != 0)
putchar('\n');
for (top = 0; top < NUM -1; top++)
for (current = top + 1; current < NUM; current++)
if (randnum[current] > randnum[top])
{
temp = randnum[current];
randnum[current] = randnum[top];
randnum[top] = temp;
}
puts("\nAfter sort:");
for (i = 0; i < NUM; i++)
{
printf("%2d ", randnum[i]);
if (i % 10 == 9)
putchar('\n');
}
if (i % 10 != 0)
putchar('\n');
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -