- 博客(22)
- 收藏
- 关注
原创 不定数个字串连接(C语言)
#include <stdio.h>#include <stdarg.h>#include <string.h>char *scat(char *dest, const char *src, ...){ va_list ap; va_start(ap, src); char *p = NULL; strncat(dest, src, strlen(src)); while ((p = va_arg(ap, char *))) { strnca
2023-03-05 11:42:42
221
原创 大数阶乘算法(只要内存够大)
调用方法看主函数#include <stdio.h>#include <stdlib.h>#include <math.h>#define PI 3.141592654#define E 2.71828182846int *fun(int n, int *count){ if (n < 0) return NULL; int bits = log10(2 * PI * n) / 2 + n * log10(n / E) + 1 +
2022-12-27 17:44:18
242
原创 单链表前m项移动到末尾
#include <stdio.h>#include <stdlib.h>typedef struct numLink{ int no; struct numLink *next;} NODE;NODE *movenode(NODE *head, int m);NODE *initLink(NODE *head, int n){ NODE *temp = head; //声明一个指针指向头结点,用于遍历链表 static NODE *last = NU
2022-12-26 21:17:59
209
原创 独立函数动态二维数组分配与释放用法
#include <stdio.h>#include <stdlib.h>//创建row行,col列的二维动态数组,返回其首地址int **make2DArray(int row, int col){ int **a, i; a = (int **)calloc(row, sizeof(int *)); for (i = 0; i < col; i++) { a[i] = (int *)calloc(col, sizeof(int)); }
2022-12-10 21:12:38
218
原创 直接选择排序算法(C语言经典算法)
#include <stdio.h>#include <stdlib.h>#include <time.h>void selSort(int arr[], int n){ int i, j, small, tmp; for (i = 0; i < n - 1; i++) { small = i; for (j = i + 1; j < n; j++) { if (arr[j] < arr[small]) smal
2022-12-08 19:04:05
221
原创 计算任何两个时刻的时间差(精确到毫秒)
#include<stdio.h>#include<stdlib.h>#include<time.h>struct t{ int year; int mon; int mday; int hour; int min; int sec; int ms;} t1, t0; // 计算两个日历的时间差,精确到毫秒double mydifftime(struct t t1, struct t t0){ time_t time1, tim
2022-08-20 12:45:27
1169
1
原创 快速排序qsort示例(标准库函数)
/* 函数原型: void qsort(void *base, int nelem, int width, int(*fcmp)(const void *, const *)) 头文件: #include<stdlib.h> 是否是标准函数:是 函数功能:对记录进行从小到大的快速排序。参数 base 指向存放待排序列的数组的首 地址, nelem 为数组中元素的个数, width 为每个元素的字节数, int(*fcmp)(const vo...
2022-08-16 17:30:57
226
1
原创 我的通讯录v1.0
用法详情看源代码:源文件:#include<conio.h>#include"wgx_contact.h"int main(int argc, char** argv){ person *info=NULL; //初始化链表 link_init(&head); //载入通讯录 默认自动加载的文件到链表 load("/storage/emulated/0/wgx_contact"); /...
2022-07-25 12:41:47
136
1
原创 my_itoa函数
#include<stdio.h>//参数r是进制数void my_itoa(int a, char *s, unsigned r){ char str[1000]; int i = 0, j = 0; if (a == 0) { *s = '0'; *(s + 1) = '\0'; return; } while (a) { *(str + i++) = a % r + 48; a /= r; } *(str + i) = '\0'; ..
2022-07-23 17:04:37
266
原创 C语言四则运算大数计算(单头文件库)
已写成单头文件库,包含即可直接调用对应函数。用法看调用函数。头文件wgx_math_calc.h//wgx_math_calc.h文件//加减乘除超大数计算#ifndef INCLUDE_WGX_MATH_CALC_H#define INCLUDE_WGX_MATH_CALC_H#ifdef __cplusplusextern "C" { #endif int s1_compare_s2(char *s1, char *s2); char* daoshu(...
2022-07-11 01:45:00
1057
原创 C语言画菜单函数(只为方便手机端学习用户)
主要针对手机端初学者用户,重复画菜单不方便调节字符空格不方便居中显示等问题。函数自动画菜单,边框字符自定义,宽高自定义,要显示的菜单写成数组,调用函数即可。注意:输出字体默认16磅大小,其它大小可能有偏差。完整代码如下,仅供参考!#include <stdio.h>#include<string.h>#include<wchar.h>#include<locale.h>int drawrect(unsigned int w,uns
2022-06-30 13:41:42
4265
原创 C语言字符串批量查找批量替换
由于本人水平有限,仅供参考!完整代码如下:#include<stdio.h>#include<stdlib.h>#include<string.h>int* getstrindex( char *,char *);char* strreplace(char *str,char *oldword,char *newword);int myfgets(char *s,unsigned int maxlen,FILE *fp);int main(i...
2022-06-28 02:33:43
1545
原创 C语言万年历
完整代码如下:#include<stdio.h>#include<time.h>#include<stdlib.h>#include<string.h>#include<conio.h>//非标准库控制台I/O//平年月份表const int mons[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//闰年月份表const int mons2[13]={0,31,...
2022-06-10 21:19:55
2099
原创 大数计算(结绳中文编程)
完整代码:覆写方法 载入布局完毕() 父对象.载入布局完毕()结束 方法变量 保留小数位数 为 整数型 = 1000;变量 bool1 为 逻辑型 = 假;变量 bool2 为 逻辑型 = 假;方法 是数字串(str 为 文本型) 为 逻辑型 变量 j 为 整数型 = 0; 变量 i 为 整数型 = 0; 变量 计数 为 整数型 = 0; 变量 bool 为 逻辑型 = 真; 变量 数字 为 文本型 = "0123456789."; 变量 s..
2022-06-02 23:51:06
510
原创 杨辉三角(C语言等腰三角形排版)
#include<stdio.h>int yanghuiSJ(int n){ int spac=n; if (n > 1000 || n <= 0) return -1; long arr[n][n]; arr[0][0] = 1; arr[1][0] = 1; arr[1][1] = 1; for (int i = 2; i < n; i++) { for (int j = 0; j <= i;...
2022-05-31 18:34:27
236
原创 随机数生成器(结绳中文app编程)
代码变量 a 为 整数型=0;覆写方法 载入布局完毕() 父对象.载入布局完毕() //初始化 文本框4.内容="0";结束 方法事件 拖动条1:进度被改变(a 为 整数型) 文本框4.内容=到文本(a); 结束 事件方法 是数字(str 为 文本型) 为 逻辑型 变量 j 为 整数型=0; 变量 bool 为 逻辑型=真; 变量 slen 为 整数型 =文本操作.取文本长度(str); 如果 slen < 1 ...
2022-05-05 23:46:17
1302
1
原创 文字转拼音(结绳中文编程工具)
下面展示一些 内联代码片。变量 文本长度 为 整数型=0;变量 字符 为 文本型="";变量 i 为 整数型=0;覆写方法 载入布局完毕() 父对象.载入布局完毕() 编辑框1.内容=""; 编辑框2.内容="";结束 方法事件 按钮1:被单击() 编辑框2.内容=""; 文本长度=文本操作.取文本长度(编辑框1.内容); 变量循环 i=0 至 (文本长度 - 1) 字符=到文本(文本操作.取指定字符(编辑框1.内容,i)); 编辑
2022-05-05 23:15:56
548
原创 C语言标准库写倒计时/已逝时间
/*********************************************说明:计算倒计时间或已逝去时主要函数:char *countdown(char *dsttimes);函数接受字串格式 如2036年10月10日10时10分10秒要写成这样:20361010101010注意:共14位数字,中间无空格,必须要上述格式输入,否则会计算有误。此函数用于计算未来时间点或者是已经逝去的时间点距至今相距多长时间倒计时/已逝时间:精确到秒********************
2021-11-24 18:32:54
1027
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人