![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c语言自写函数系列
自写函数
wenson0705
这个作者很懒,什么都没留下…
展开
-
算法-用C语言实现
1.交换两个变量的值,不使用第三个变量,即a=3, b=5, 交换后b=3, a=5。 unsigned char a = 3, b = 5; a = a + b; b = a - b; a = a - b;或者 a = a ^ b; b = a ^ b; a = a ^ b;如果写成函数:void swap(int*...原创 2020-04-17 18:44:39 · 932 阅读 · 0 评论 -
c语言实现的一些解决数学问题的函数
1.求x的n次幂的函数int what ( int x , int n){ int val; int product; product = 1; val = x; while (n > 0) { if (n%2 == 1) product = product * val; /*如果是奇数次幂, x(v...原创 2020-04-16 13:03:31 · 596 阅读 · 0 评论 -
c语言实现进制转换函数
1。编写一个函数,输入一个的整型数字,可以选择按照8/10/16进制输出字符串。采用递归形式实现#include<stdio.h>void number_print(int i_num, int type) // type为8、10、16{ int divisor; // 除数 int remainder; // 余数 divisor = i_n...原创 2020-04-16 11:26:23 · 3805 阅读 · 0 评论 -
用c实现部分位操作函数
1.计算一个char型字节里(byte)里面有多少bit被置1int bit_set_counts_of_one_byte(char byte){ int count = 0; while (byte) { // byte里面的1右移完之后会变为0 if (byte & 1) { count++; } byte >>= 1; } return ...原创 2020-04-13 18:00:40 · 323 阅读 · 0 评论 -
用c实现的部分字符串操作函数
1.将一个数字字符串转换为数字."1234" --> 1234//将一个数字字符串转换为数字."1234" --> 1234#include<stdio.h>int convert(char *str){ int k = 0; while(*str != '\0') { k = k * 10 + (*str++) - '0';//字符数ASKII码-...原创 2020-04-13 17:58:28 · 321 阅读 · 0 评论 -
约瑟夫环问题:用户输入M,N值,从1至N开始顺序循环数数,每数到M输出该数值,直至全部输出。
#include<stdio.h>#include<stdlib.h>typedef struct josephnum{ int num;//1-N连续数字 struct josephnum *front;//前指针 struct josephnum *next;//后针域}JCN;void print_help(){ p...原创 2020-04-13 15:52:05 · 488 阅读 · 0 评论 -
c语言实现歌词播放效果(初级)
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<unistd.h>typedef struct lrc{ int m_time; char lrc_buf[200]; struct lrc *front; struct lrc *next;}LRC;...原创 2020-04-12 14:12:13 · 1169 阅读 · 2 评论 -
c语言单向链表和双向链表的操作
#include<stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>typedef struct student{ int num;//学号 char name[10];//姓名 struct student *next;//指针域}...原创 2020-04-12 14:03:16 · 294 阅读 · 0 评论 -
分割字符串为一组字符串,打开文件一般流程,加解密文件一般流程
分割字符串为一组字符串int msg_deal(char *msg_src,char *msg_done[],char *str)//分割字符串为一组字符串{//msg_src这个是源文本,msg_done:分割后的存储数组,str:以str指定的字符分割 int i=0; msg_done[i] = strtok (msg_src,str); while(msg_done[i] !...原创 2020-04-12 13:54:41 · 101 阅读 · 0 评论