#include <stdlib.h>
#include <string.h>
#include <time.h>
const int MAXLEN = 18
void sort(char s[][MAXLEN],int n) {
int i,j,k
char tmp[MAXLEN]
for(i = 0 i < n - 1 ++i) {
k = i
for(j = i + 1 j < n ++j) {
if(strcmp(s[k],s[j]) > 0) k = j
}
if(i != k) {
strcpy(tmp,s[k])
strcpy(s[k],s[i])
strcpy(s[i],tmp)
}
}
}
int main() {
int i,j,n = 10
char s[10][MAXLEN]
srand((unsigned)time(NULL))
for(i = 0 i < n ++i) {
for(j = 0 j < MAXLEN - 1 ++j) {
if(rand()%2) s[i][j] = rand() % ('z' - 'a') + 'a'
else s[i][j] = rand() % ('Z' - 'A') + 'A'
}
s[i][j] = '\0'
}
printf("排序前:\n")
for(i = 0 i < n ++i) printf("%s\n",s[i])
sort(s,n)
printf("排序后:\n")
for(i = 0 i < n ++i) printf("%s\n",s[i])
return 0
}
急求,马上给分,还加分 我把程序下载进单片机,有一个灯一直闪,我没按按键也闪。也就是有一个中断没发生也闪,麻烦高手修改完发给我,谢谢!#include
#define uint unsigned int
#define uchar unsigned char
sbit LED=P0^0
sbit LED1=P0^1
void delay1ms (uint z)
{
uint x,y
for (x=zx>0x--)
for (y=110y>0y--)
}
void exter() interrupt 2
{
delay1ms(600)
LED=0
delay1ms(200)
LED=1
}
void exter0() interrupt 0
{
delay1ms(600)
LED1=0
delay1ms(200)
LED1=1
}
main()
{
EA=1//开总中断
EX1=1//开外部中断1
EX0=1//开外部中断0
IT1=0//外部中断边沿触发,下降沿触发
IT0=0//外部中断0边沿触发,下降沿触发
}