📄 exp07_05.c
字号:
#include <stdio.h>
#include <conio.h>
#include <alloc.h>
main()
{
int *p;
int num,i;
int maxindex,minindex;
printf("input the number of student:");
scanf("%d",&num);
p=(int *)malloc(num*sizeof(int));
if(p==NULL)
{
printf("no enough memory\n");
return;
}
printf("input the marks of students now:\n");
for(i=0;i<num;i++)
scanf("%d",p+i);
//search the max and min mark
maxindex=minindex=0;
for(i=1;i<num;i++)
{
if(p[i]>p[maxindex])
maxindex=i;
if(p[i]<p[minindex])
minindex=i;
}
//output the number
for(i=0;i<num;i++)
{
if(i==maxindex)
textcolor(RED);
else if(i==minindex)
textcolor(BLUE);
else
textcolor(WHITE);
cprintf("%d\n\r",p[i]);
}
free(p);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -