张麻子


私信TA

用户名:qwezjh

访问量:2460

签 名:

上任鹅城

等  级
排  名 835
经  验 3498
参赛次数 0
文章发表 25
年  龄 0
在职情况 学生
学  校 asd
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include "stdio.h"

void swap(int* a, int* b) 

{

int temp = *a;

*a = *b;

*b = temp;

}

void quicksort(int array[], int low, int high) 

{

int i = low, j = high;

if (i >= j) { return; }

int temp = array[low];

while (i != j) 

{

while (array[j] >= temp && j > i) 

{

j--;

}

while (array[i] <= temp && i < j) 

{

i++;

}

if (i < j) 

{

swap(&array[i], &array[j]);

}

}

swap(&array[i], &array[low]);

quicksort(array, low, j - 1);

quicksort(array, j + 1, high);

}

int main() 

{

int n, num[100000], k;

scanf("%d%d", &n,&k);

for (int i = 0; i < n; i++) 

{

scanf("%d", &num[i]);

}

quicksort(num,0,n-1);

for (int i = 0; i < n; i++) 

{

if (num[i] % k == 0) { continue; }

if (num[i] >= (int)'A' && num[i] <= (int)'Z') 

{

printf("%c ", num[i]);

continue;

}

printf("%d ", num[i]);

}

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区