![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
垃圾桶
以回忆来让自己前进,存放的旧代码
语言是窗
普通学生
展开
-
【javascript素数函数实现】
【代码】【javascript素数函数实现】原创 2023-02-04 08:25:24 · 173 阅读 · 0 评论 -
关于我写博客的问题
这两天,在B站刷到写博客有多重要首先,这个视频有三个小时多,目前两天我还没有看完它,时间分配的还不够好从昨天就打算开始写博客,但是由于也没有开始学C语言,就没写博客今天也是一样,没有学C语言,但是我不能不发了我不能有三分钟热度...原创 2022-04-11 20:46:12 · 470 阅读 · 0 评论 -
【C语言函数3.3】函数的嵌套调用和链式访问
写一个函数, 每调用一次这个函数, 就会将num的值增加1#include <stdio.h>void Add(int *p){ (* p)++;}int main(){ int num = 0; Add(&num); printf("%d\n", num); Add(&num); printf("%d\n", num); Add(&num); printf("%d\n", num); return 0;}函数不能嵌套定义,但是可以嵌原创 2022-04-19 20:36:01 · 493 阅读 · 0 评论 -
【C语言函数学习篇2】
#include <stdio.h>int get_max(int x, int y){ int z = 0; if (x > y) z = x; else z = y; return z;//返回最大值}int main() { int a,b; a = 8; b = 9; //函数的调用 int max = get_max(a, b); printf("max = %d", max);}我让张三(get_max)带一份饭(蛋炒饭,20元.原创 2022-04-14 09:23:42 · 326 阅读 · 0 评论 -
【C语言函数3.2】写一个函数,实现一个整形有序数组的二分查找代码
写一个函数,实现一个整形有序数组的二分查找代码#include <stdio.h>int binary_search(int a[], int k, int s){ int left = 0; int right = s-1; while (left <= right) { int mid = (left + right) / 2; if (a[mid] > k) { right = mid - 1; } else if (a[mid] &l原创 2022-04-18 19:40:22 · 1174 阅读 · 2 评论 -
【C语言】函数递归1
什么是函数递归?就是自己调用自己#include <stdio.h>int main(){ //函数自己调用自己 //当前代码会栈溢出 printf("hehe\n"); main(); return 0;}原创 2022-04-24 09:14:45 · 1032 阅读 · 0 评论 -
【C语言函数3.1】函数判断闰年
使用函数实现1000-2000的闰年#include <stdio.h>int is_leap_year(int n){ return ((n % 4 == 0 && n % 100 != 0) || (n % 400 == 0));}int main(){ int y; for (y = 1000; y <= 2000; y++) { if (is_leap_year(y) == 1) { printf("%5d", y); } }原创 2022-04-17 08:41:20 · 415 阅读 · 0 评论 -
【C语言接触函数】一个早晨突然收到一句话: 人家不会在跳进坑里了
//被5整除#include <stdio.h>int main(){ int m = 0; scanf_s("%d", &m); if (m % 5 == 0) { printf("YES"); } else { printf("NO"); } return 0;}//小飞机#include <stdio.h>int main(){ printf(" ** \n"); printf(" ** \n");原创 2022-04-12 20:17:36 · 48 阅读 · 0 评论 -
【C语言函数2.1】通过指针并利用函数交换两个数的值
#include <stdio.h>//通过指针并利用函数交换两个数的值void Swap(int* pa, int* pb){ int z = 0; z = *pa; *pa = *pb; *pb = z;}int main(){ int a, b; a = 10; b = 20; printf("交换前a=%d,b=%d\n", a, b); Swap(&a, &b); printf("交换后a=%d,b=%d\n", a, b); //初识原创 2022-04-15 09:12:15 · 969 阅读 · 0 评论 -
【C语言初识结构体】
#include <stdio.h>struct Stu{ char name[20]; int age; double score;};struct Book{ char name[20]; float price; char id[30];};int main(){ struct Stu s = { "张三",20,85.5 };//结构体创建和初始化 printf("1: %s %d %lf\n", s.name, s.age, s.score);//结原创 2022-03-23 14:40:29 · 803 阅读 · 0 评论 -
【C语言】函数递归2
自行写一个求字符串长度的函数(使用临时变量实现)#include <stdio.h>#include <string.h>int my_strlen(char* str){ int count=0; while (*str != '\0') { count++; str++; } return count;}int main(){ char arr[] = "bit"; printf("%d\n", my_strlen(arr)); retur原创 2022-04-30 10:03:23 · 123 阅读 · 0 评论 -
【C语言函数入门】strcpy,memset例子
#include <stdio.h>#include <string.h>int main(){ char arr1[20] = { 0 }; char arr2[] = "hello"; strcpy(arr1, arr2); printf("%s", arr1); return 0;}编译执行,出现了这个错误This function or variable may be unsafe. Consider using strcpy_s instead. To原创 2022-04-13 14:15:33 · 383 阅读 · 0 评论 -
【C语言函数3】实参形参,使用函数实现素数判断
(形式参数)函数定义, 不使用的话,不会分配空间形式参数调用完会自动的销毁传值调用 不修改原来的值传址调用 修改自身的值传值的是实参定义的函数是形参使用函数判断素数#include <stdio.h>#include <math.h>int is_prime(int n){ int j = 0; //sqrt 比如25,开平方以后是5,那么整除2-5就可以了 for (j = 2; j <= sqrt(n); j++) { if (n % j原创 2022-04-16 10:28:29 · 383 阅读 · 0 评论