题目
给定某整数数组和某一整数b。要求删除数组中可以被b整除的所有元素,同时将该数组各元素按从小到大排序。如果数组元素数值在A到Z的ASCII之间,替换为对应字母。
输入
第一行为数组元素个数和整数b
第二行为数组各个元素
元素个数不超过100,b在1至100之间。
输出
按照要求输出
样例输入
7 2
77 11 66 22 44 33 55
样例输出
11 33 55 M
代码
#include<stdio.h>
int main()
{
int i,b,c,temp,has_printed=0,k=0;
char character[1000];
scanf("%d %d\n",&b,&c);
for (i=0;i<b;i++)
{
scanf("%d",&temp);
if (temp%c!=0)
{
if (temp>='A' && temp<='Z')
character[k++] = temp;
else
{
if (has_printed==1)
printf(" ");
printf("%d",temp);
has_printed = 1;
}
}
}
for (i=0;i<k;i++)
{
if (has_printed==1)
printf(" ");
printf("%c",character[i]);
}
return 0;
}