![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C语言
王文搏
学生
展开
-
C语言删除字符串中某一指定字符
C语言删除字符串中某一指定字符原创 2022-12-25 09:30:56 · 4544 阅读 · 4 评论 -
输入一个数计算输出从0到该数的阶乘
输出从0到该数的阶乘原创 2022-08-29 10:55:37 · 422 阅读 · 0 评论 -
python 和c 语言区别 (自我理解)
1、定义不同:c语言定义一个数字时要明确定义数字类型,而python直接定义不用写出被定义内容的类型。2、写c语言需要引用函数的头文件,而python不用引用任何头文件,除非是调用一些文件时需要引用文件名。3、python的循环语句的语法不同于其他语言,python时一门胶水语言,融合了很多语言的优点,,本人学习过的高级语言有Java和c还有python,前两者的for 和 while循环基本预压一样,但是python过于简化就是在一个for循环上可以实现更多的内容,这样是可以少些代码,但是不方便新原创 2021-09-28 18:44:28 · 5850 阅读 · 0 评论 -
输入年月日判断这是几年几月几日
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>int input(int year,int month,int day) { if (month == 2 && 0 < day <= 28) { return day; } else if (month == 7 && 0 <.原创 2021-09-05 16:31:40 · 328 阅读 · 0 评论 -
判断一个数字是不是回文数
回文数定义:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>int test(int a) { //思路拿出个位和万位比较,再拿出十位和千位比较 int b = a; int c = a; int d = a; if (a % 10 =原创 2021-09-05 10:16:48 · 522 阅读 · 0 评论 -
猴子吃桃桃
猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个第二天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘了多少。#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>int main(){ //设第一天有x个桃 int x = 0原创 2021-09-04 11:37:34 · 56 阅读 · 0 评论 -
逆序一个字符串(不是逆序打印)
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>void rev(char* arr,int len) { assert(*arr); int left = 0; int right = len; char tmp; while (left < right) { tmp = arr[left]; arr[lef.原创 2021-08-25 19:30:44 · 47 阅读 · 0 评论 -
strstr函数(用来比较两个字符串大包含关系)的实现原理
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>int my_strstr(const char* arr1, const char* arr2) { assert(arr1 && arr2); while (*arr1) { if (*arr1 == *arr2 && *arr1 != '\0.原创 2021-08-25 19:08:53 · 276 阅读 · 0 评论 -
库函数strcmp的实现原理(判断两个字符串是否相等)
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>int my_strcmp(const char* arr1, const char* arr2) { assert(arr1 && arr2); while (*arr1 == *arr2) { if (*arr1 == '\0' && *arr.原创 2021-08-24 19:35:07 · 590 阅读 · 0 评论 -
库函数strcat 的实现原理(追加字符串)
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>void my_strcat(char* arr1, char* arr2) { assert(arr1 && arr2);//指针断言,防止传进来的是空指针 while (*arr1) {//找到arr1中‘\0’的位置 arr1++; } while (*.原创 2021-08-24 17:14:04 · 224 阅读 · 0 评论 -
库函数strcpy 的实现原理
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>//库函数strcpy被定义的时候返回的是char*,这里自己定义可以用 voidvoid my_strcpy(char* arr1, char* arr2) { assert(arr1 && arr2);//指针断言,防止传进来的是空指针 while (*arr2.原创 2021-08-24 16:58:00 · 555 阅读 · 0 评论 -
打印一个菱形
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>void Lingxing_up(int k) { //思路:每一行需要先打印空格在打印*,假设行数就等于改行的*的个数,且第一行有k个空格 int i = 1; int m = 0;//每一行打印空格的个数,由于每一行打印的空格数不同所以这是个变量 int n = 0;//每一.原创 2021-08-24 16:36:54 · 120 阅读 · 0 评论 -
打印三角形(或菱形上半部分)
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>#include <assert.h>void Lingxing_up(int k) { //思路:每一行需要先打印空格在打印*,假设行数就等于改行的*的个数,且第一行有k个空格 int i = 1; int m = 0;//每一行打印空格的个数,由于每一行打印的空格数不同所以这是个变量 int n = 0;//每一.原创 2021-08-24 10:59:09 · 94 阅读 · 0 评论 -
在杨氏矩形中寻找一个数
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>int find_s(int arr[3][3],int x,int y,int a) { while (x <=2&&y>=0) { //从矩形的右上角逐行逐列寻找 if (a > arr[x][y]) { //住行寻找 x++; } else if (a < arr[.原创 2021-08-23 15:58:18 · 54 阅读 · 0 评论 -
实现数组的左旋或者右旋
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>void menu(){ printf("###开始###\n"); printf("###输入1左旋,输入2右旋\n");}void reverse(char *left,char *right) { while (left < right) { char tmp = *left; *left = *right;.原创 2021-08-23 14:51:16 · 130 阅读 · 0 评论 -
用C语言实现左逆序选中元素
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>#include <string.h>void reverse(char *left,char *right) { while (left < right) { char tmp = *left; *left = *right; *right = tmp; left++; right--; }}void lelft_move(char* ar.原创 2021-08-22 19:29:41 · 67 阅读 · 0 评论 -
加减乘除计算器
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>int main() { int i = 0; int a = 0; int b = 0; int z = 0; printf("######输入1进行加法运算######\n"); printf("######输入2进行减法运算######\n"); printf("######输入3进行乘法运算######\n"); printf("######输入1进行除法运算##.原创 2021-08-22 11:14:25 · 119 阅读 · 0 评论 -
查询数组中是否有自己想要的数字
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>int main() { int a = 0; int i = 0; int arr[] = { 1,2,3,4,5,6,7,8,9,0 }; printf("请输入您想查找的数字"); scanf_s("%d", &a); int sz = sizeof(arr) / sizeof(arr[0]); for (i = 0; i < sz; i++) { .原创 2021-08-22 10:49:40 · 192 阅读 · 0 评论 -
用c语言实现冒泡排序
void Uzi(int arr[],int sz) { int i = 0; int j = 0; for (i = 0; i <= sz-1; i++) { for (j = 0; j < sz - 1 - i; j++) { if (arr[j] < arr[j + 1]) { int tmb = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = tmb; } } } }int main(.原创 2021-08-18 20:11:14 · 80 阅读 · 0 评论 -
C语言中strlen的实现
#define _CRT_SECURE_NO_WARNINGD 1#include <stdio.h>int slen(char * arr) { int count=0; while (*arr) { arr++; count++; } return count;}int main() { char arr[] = "wangwenbo"; int len = slen(arr); printf("%d", len); return 0;}原创 2021-08-21 21:09:43 · 90 阅读 · 0 评论