Algorithm training array Find and replace time limit: 1.0s memory Limit: 512.0MB problem description Given an array of integers and an integer b. Requires that all elements in an array that are divisible by B be deleted, and that the elements of the array are sorted from small to large. If the array element values are between A and z ASCII, replace with the corresponding letter. The number of elements does not exceed 100,b between 1 and 100. Input format first behavior array element number and integer b
Second behavior array element output format output sample input as required 7 2 77 11 66 22 44 33 55
Sample output
M
Example code:
1#include <iostream>2#include <algorithm>3 using namespacestd;4 5 #defineMax_num 1016 7 intMain ()8 {9 intN, b;Tenscanf"%d%d", &n, &b); One A intArr[max_num]; - - inttmp; the intK =0; - for(inti =0; I < n; i++)//Find - { -scanf"%d", &tmp); + if(tmp% B! =0) - { +arr[k++] =tmp; A } at } - -Sort (arr, arr + k);//Sort - - for(inti =0; I < K; i++)//Replace - { in if(Arr[i] >= $&& Arr[i] <= -) -printf"%c", Arr[i]); to Else +printf"%d", Arr[i]); - } the * return 0; $}
Blue Bridge cup algorithm training ALGO-50 array Find and replace