- 博客(26)
- 收藏
- 关注
原创 链表内部交换(交换结点指针域)
void sort(void){ Node* pi = head; while (pi != NULL) { int sum = 0; for (int cnt = 0; cnt < 4; cnt++) { sum += pi->score[cnt]; } pi->total = sum; pi->average = (double)(sum) / 4; pi = pi->next; } Node* headp = (Node*).
2021-12-17 21:32:27
1630
原创 贪吃蛇小游戏(C语言实现)
#include<stdio.h>#include<stdlib.h>#include<time.h>#include<Windows.h>#include<conio.h>#include<stdbool.h>#define up 'w'#define down 's'#define left 'a'#define right 'd'void welcome(void); //欢迎界面的打印void g.
2021-12-04 23:44:01
434
原创 二分查找(C语言实现)
int score1;int panduan = 0;scanf("%d", &score1);while (left <= right){ int middle = (left + right) / 2; if (list[middle].score == score1) { printf("%s %d\n", list[middle].name, list[middle].score); panduan = 1; } if (score1 > list[m.
2021-12-02 22:17:50
237
原创 编写自己的字符串删除特定字符函数
void strdelc(char s[], char c){ int j, k; for (j = k = 0; s[j] != '\0'; j++) { if (s[j] != c) s[k++] = s[j]; } s[k] = '\0';}只用一个数组,并且是原来那个字符数组我们使用两个游标,一个游标用来读,另一个用来写,当读到要删除的特定字符时,我们就不写入这个字符,反之,都要把字符写入。...
2021-12-01 12:13:07
546
原创 01迷宫路线设计
#include<stdio.h>typedef struct a { int time; int value; double average; }hurb;void maopao(hurb num[], int n);int main(void){ int time, M; scanf_s("%d %d", &time, &M); hurb num[1000]; //2. for (int cnt = 0; cnt < M; cnt++) { s.
2021-11-29 21:02:59
914
原创 利用递归判断回文数
#include<stdio.h>#include<string.h>#define SIZE 100int isPalindrome(char arr[], int len);int main(){ char str[SIZE]; scanf_s("%s",str,SIZE); int length = strlen(str); if (isPalindrome(str, length)) { printf("Yes"); } else { pr.
2021-11-26 21:44:21
2440
原创 P1011 [NOIP1998 提高组] 车站
#include<stdio.h>typedef struct a { int time; int value; double average; }hurb;void maopao(hurb num[], int n);int main(void){ int time, M; scanf_s("%d %d", &time, &M); hurb num[1000]; //2. for (int cnt = 0; cnt < M; cnt++) { s.
2021-11-22 19:14:14
658
原创 P1048 [NOIP2005 普及组] 采药
#include<stdio.h>typedef struct a { int time; int value; double average; }hurb;void maopao(hurb num[], int n);int main(void){ int time, M; scanf_s("%d %d", &time, &M); hurb num[1000]; //2. for (int cnt = 0; cnt < M; cnt++) { s.
2021-11-22 19:04:12
301
原创 洛谷-P1003 [NOIP2011 提高组] 铺地毯
#include<stdio.h>int num[10000][10000] = { 0 };int main(void){ //1 int n; scanf_s("%d", &n); //2 int x, y, g, k; for (int cnt = 1; cnt <= n; cnt++) { scanf_s("%d %d %d %d", &x, &y, &g, &k); for (int hang = y; hang.
2021-10-31 21:12:48
249
原创 快速排序(递归版)
void qsort(int a[], int begin, int end){ if (begin > end) return; int left = begin; int right = end; int key = a[begin]; while (begin < end) { while (a[end] >= key && begin < end) { end--; } a[begin] = a[end]; whi.
2021-10-16 17:17:31
74
原创 1015 德才论 (25 分)
#include<stdio.h>typedef struct student{ int id; int de; int cai;} STU;//void maopao(STU a[], int length);void print1(STU a[], int length);void print2(STU a[], int length);void qsort(STU a[], int begin, int end);STU level1[1000000], level.
2021-10-16 16:41:32
80
原创 1015 德才论 (25 分)
#include<stdio.h>void maopao(struct student a[], int length);void print1(struct student a[], int length);void print2(struct student a[], int length);struct student{ int id; int de; int cai;};int main(void){ //1.读入三个数 int N, L, H; scanf_.
2021-10-14 17:32:19
80
原创 1014 福尔摩斯的约会 (20 分)
#include<stdio.h>#include<string.h>int main(void){ //1.读入字符串 char a[100] = { 0 }; char b[100] = { 0 }; char c[100] = { 0 }; char d[100] = { 0 }; scanf_s("%s", a, 100); scanf_s("%s", b, 100); scanf_s("%s", c, 100); scanf_s("%s", d, .
2021-10-11 22:50:30
66
原创 1013 数素数 (20 分)
#include<stdio.h>#include<math.h>int main(void){ int num; int m; int n; scanf_s("%d", &m); scanf_s("%d", &n); int cnt = 0; int count = 0; int i; for (num = 2; count <= n; num++) { int process = 0; for (i = 2; i <.
2021-10-11 17:14:17
81
原创 1012 数字分类 (20 分)
#include<stdio.h>int main(void){ int a1 = 0, a2 = 0, a3 = 0, a5 = 0; float a4 = 0.0; int cnt1, cnt2, cnt3, cnt4, cnt5; cnt1 = cnt2 = cnt3 = cnt4 = cnt5 = 0; int n; int count; int num = 0; int i = 0; int sum = 0; scanf_s("%d", &n); f.
2021-10-11 17:06:43
73
原创 1010 一元多项式求导 (25 分)
#include<stdio.h>int main(void){ //1.输入数组 int number[3000] = { 0 }; int cnt; char ch = 'a'; for (cnt = 0; ch != '\n'; cnt++) { scanf_s("%d", &number[cnt]); ch = getchar(); } cnt--; int n = cnt; //printf("%d", cnt); /*int n = cnt.
2021-10-09 18:06:56
108
原创 1008 数组元素循环右移问题 (20 分)
#include<stdio.h>int main(void){ //1.读取N和M int N, M; scanf_s("%d", &N); scanf_s("%d", &M); int move = M; //2.把数据读进数组并复制 int cnt; int number[1000] = { 0 }; for (cnt = 1; cnt <= N; cnt++) { scanf_s("%d", &number[cnt]); }.
2021-10-09 17:50:19
91
原创 1009 说反话 (20 分)
#include<stdio.h>int main(void){ char ch; char a[81][81] = { '0'}; int cnt = 1; scanf_s("%s", a[cnt],81); cnt++; ch = getchar(); for (; ch != '\n'; cnt++) { scanf_s("%s", a[cnt], 81); ch = getchar(); } /*for (; cnt >= 1; cnt--) {.
2021-10-08 18:11:30
90
原创 1007 素数对猜想 (20 分)
#include<stdio.h>#include<math.h>int main(void){ //1.读取数字 int n; scanf_s("%d", &n); //2.得到所有素数 int number; int cnt; int i = 0; int a[10000] = { 0 }; int temp = 0; for (number = 2; number <= n; number++) { int judge = 0;.
2021-10-07 18:11:13
105
原创 1005 继续(3n+1)猜想 (25 分
#include<stdio.h>int main(void){ //1.读取数字 int n; scanf_s("%d", &n); //2.把给定数读入数组 int cnt; int number[100]; int cnt2 = 0; for (cnt = 0; cnt < n; cnt++) { scanf_s("%d", &number[cnt]); } /*for (cnt = 0; cnt < n; cnt++) {.
2021-10-06 18:19:02
48
原创 冒泡排序c语言实现
#include<stdio.h>void maopao(int a[], int length);int main(void){ int n; scanf_s("%d", &n); int num[100] = { 0 }; for (int cnt = 0; cnt < n; cnt++) { scanf_s("%d", &num[cnt]); } maopao(num, n); for (int cnt = 0; cnt < n; c.
2021-10-06 18:17:31
62
原创 1006 换个格式输出整数 (15 分)
#include<stdio.h>#include<string.h>int main(void){ //1.读取位数 char num[1000] = {0}; int n; scanf_s("%s", num, 1000); n = strlen(num); //printf("%d", n); //2.判断位数 if (n == 3) { int bai = num[0] - '0'; for (; bai > 0; bai--) .
2021-10-05 19:55:02
55
原创 1004 成绩排名 (20 分)
#include<stdio.h>int main(void){ //1.读取数字 int n; scanf_s("%d", &n); //2.读取每一行的三个数据 int cnt; char name[101][11]; char id[101][11]; int score[101]; for (cnt = 0; cnt < n; cnt++) { scanf_s("%s", name[cnt], 101); scanf_s("%s", id.
2021-10-05 18:05:35
70
原创 1002 写出这个数 (20 分) C语言实现
#include<stdio.h>int main(void){ char num[101]; int sum = 0; int i = 0; char c[10][10] = { "ling","yi","er","san","si","wu","liu","qi","ba","jiu" }; num[i] = getchar(); while (num[i] != '\n') { sum += num[i] - '0'; i++; num[i] = getch.
2021-10-04 20:21:07
183
原创 1003 我要通过! (20 分) c语言实现
#include<stdio.h>#include<string.h>int main(void){ //1.将字符串输入进数组 char c[10][101]; int i; int cnt; scanf_s("%d", &i); for (cnt = 0; cnt < i; cnt++) { scanf_s("%s", c[cnt], 101); } /*for (cnt = 0; cnt < i; cnt++) { pri.
2021-10-04 18:23:23
261
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人