- 博客(16)
- 收藏
- 关注
原创 //有三个方法,分别实现返回姓名和两门课成绩(总分),返回姓名和三门课成绩(总分), // 返回姓名和五门课成绩(总分)。封装成一个可变参数的方法
【代码】//有三个方法,分别实现返回姓名和两门课成绩(总分),返回姓名和三门课成绩(总分), // 返回姓名和五门课成绩(总分)。封装成一个可变参数的方法。
2025-03-14 16:28:57
114
原创 autojs的intent的基本应用简单使用,附加跳转支付宝转账代码
> Intent(意图) 是一个消息传递对象,可以使用它从其他应用组件请求操作。启动活动(Activity): Activity> 表示应用中的一个"屏幕"。根据选项构造一个Intent,并启动该Activity。app.startActivity(options) > options {Object} 选项
2023-02-15 08:23:12
2459
原创 【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
215
原创 【C语言】函数递归1
什么是函数递归?就是自己调用自己#include <stdio.h>int main(){ //函数自己调用自己 //当前代码会栈溢出 printf("hehe\n"); main(); return 0;}
2022-04-24 09:14:45
1127
原创 【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
566
原创 【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
1337
2
原创 【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
490
原创 【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
466
原创 【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
1116
原创 【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
379
原创 【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
467
原创 【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
92
原创 关于我写博客的问题
这两天,在B站刷到写博客有多重要首先,这个视频有三个小时多,目前两天我还没有看完它,时间分配的还不够好从昨天就打算开始写博客,但是由于也没有开始学C语言,就没写博客今天也是一样,没有学C语言,但是我不能不发了我不能有三分钟热度...
2022-04-11 20:46:12
511
原创 【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
920
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅