llllmz

导航

2024年1月13日

KY199 查找C

摘要: C写个快排就行了。 #include<stdio.h> #include<stdlib.h> #include<stdbool.h> int divide(int* A,int head, int tail){ if(head==tail) return head ; int x =A[head]; 阅读全文

posted @ 2024-01-13 16:02 神奇的萝卜丝 阅读(13) 评论(0) 推荐(0)

KY199 查找C++

摘要: 二分查找,没什么好说的。关键在于排成有序数组。然而C++调用sort就可以了。 #include<iostream> #include<algorithm> #include<cstdlib> using namespace std; bool judge(int* A, int n ,int t) 阅读全文

posted @ 2024-01-13 15:30 神奇的萝卜丝 阅读(25) 评论(0) 推荐(0)

KY158 找xC

摘要: #include<stdio.h> #include<stdlib.h> int main(){ int n = 0; while(scanf("%d",&n)!=EOF){ int* A=(int*)malloc(sizeof(int )*n); for(int i = 0 ; i < n ;i+ 阅读全文

posted @ 2024-01-13 15:06 神奇的萝卜丝 阅读(31) 评论(0) 推荐(0)

KY158 找xC++

摘要: 摆了几天,重新再来学习。 ‘ 把数据输入数组,然后遍历数组就行了,没什么难度。 #include<iostream> #include<cstdlib> using namespace std; int main(){ int n; while(cin >> n){ int* A=(int*)mal 阅读全文

posted @ 2024-01-13 14:56 神奇的萝卜丝 阅读(42) 评论(0) 推荐(0)

2024年1月8日

KY2 成绩排序C

摘要: 创建一个结构体,然后按要求快排就行了。 #include <stdio.h> #include <stdlib.h> typedef struct node{ int num; char S[100]; int score; }student; int divide1(student* A,int 阅读全文

posted @ 2024-01-08 15:59 神奇的萝卜丝 阅读(63) 评论(0) 推荐(0)

2024年1月7日

KY2 成绩排序C++

摘要: 用C++库函数sort秒杀了,建一个结构体就好了,同时储存输入次序。 #include<iostream> #include<algorithm> #include<cstdlib> using namespace std; struct node{ int num; char x[20]; int 阅读全文

posted @ 2024-01-07 23:28 神奇的萝卜丝 阅读(25) 评论(0) 推荐(0)

经典算法题之成绩排序C

摘要: #include<stdio.h> typedef struct node{ int num; int data; }student; int divide1(student A[],int head,int tail){ if(head==tail) return head; int t=A[he 阅读全文

posted @ 2024-01-07 21:52 神奇的萝卜丝 阅读(25) 评论(0) 推荐(0)

经典算法题之-成绩排序C++

摘要: sort实在是太好用了。活用sort,一切排序题目都可以秒杀。 #include <iostream> #include <algorithm> using namespace std; struct node{ int num; int date; }; typedef struct node s 阅读全文

posted @ 2024-01-07 16:54 神奇的萝卜丝 阅读(208) 评论(0) 推荐(0)

经典算法之-整数奇偶排序C

摘要: #include <stdio.h> int divide(int A[],int head,int tail){ if(head==tail) return head; int t=A[head]; while(head<tail){ while(head<tail && A[tail]>t ) 阅读全文

posted @ 2024-01-07 11:42 神奇的萝卜丝 阅读(35) 评论(0) 推荐(0)

经典算法题之整奇偶排序C++

摘要: 建两个数组就好了,一个存奇数一个存偶数,然后sort一下,最后输出。 #include <iostream> #include <algorithm> using namespace std; bool comp(int left,int right){ if(left > right) retur 阅读全文

posted @ 2024-01-07 11:19 神奇的萝卜丝 阅读(128) 评论(0) 推荐(0)