#define_CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<algorithm>usingnamespace std;//compare函数不交换返回trueboolcompare(int a,int b){//1.a奇数,b偶数,不交换//2.a奇数,b奇数,a比b大,不交换//3.a偶数,b偶数,a比b小,不交换//4.其他情况,交换if(a %2==1&& b %2!=1){returntrue;}elseif(a %2==1&& b %2==1&& a > b){returntrue;}elseif(a %2==0&& b %2==0&& a < b){returntrue;}else{returnfalse;}}intmain(){int arr[10];for(int i =0; i <10; i++){scanf("%d",&arr[i]);}sort(arr, arr +10, compare);for(int i =0; i <10; i++){printf("%d ", arr[i]);}printf("\n");return0;}
2024每日刷题(110)
Leetcode—535. TinyURL 的加密与解密 实现代码
class Solution {
public:// Encodes a URL to a shortened URL.string encode(string longUrl) {while(!urlToCode.count(longUrl)) {string code;for(int i 0; i < 6; i) {code…