浅浅的随笔
`#define _CRT_SECURE_NO_WARNINGS 1
//创建一个字符char a[10]
//键盘输入十个字母并输出
//找出ASCII最大值和最小值的字母
//对数组进行排序(降序)
#include <stdio.h>
#define N 10
int main()
{
char arr[N] = { 0 };//创建数组
int i = 0;
printf("输入10个字母\n");
for (i = 0; i < N; i++)
{
if (i < 0)
{
i = 0;
}//防止i变为-1
for (i = 0; i < N; i++)
{
scanf("%c", &arr[i]);
if (arr[i] == ' ')
{
i--;//使空格项重新输入
}
}
}
for (i = 0; i < N; i++)
{
printf("%c ", arr[i]);
}
printf("\n");
char max = arr[0];
char min = arr[0];
for (i = 1; i < N; i++)//找出最大最小
{
if (arr[i] > max)
{
max = arr[i];
}
if (arr[i] < min)
{
min = arr[i];
}
}
printf("max= %c\n", max);
printf("min= %c\n", min);
int j = 0;
for (j = 0; j < N - 1; j++)//冒泡排序
{
for (i = 0; i < N - 1 - j; i++)
{
if (arr[i] < arr[i + 1])
{
char tmp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = tmp;
}
}
}
for (i = 0; i < N; i++)//输出结果
{
printf("%c ", arr[i]);
}
return 0;
}`
标签:11,arr,27,min,++,max,char,printf,码值
From: https://www.cnblogs.com/CxstaR/p/18571853