原创 【C語言】編寫一個函數,將一個數字字符串轉換成該字符串對應的數字(包括正整數、負整數)

/* 編寫一個函數,將一個數字字符串轉換成該字符串對應的數字(包括正整數、負整數) 例如:"12" 返回12 "-123" 返回-123 函數原型:int my_atof(char *str) */ #include <stdio

原创 【C語言】最大公約數(更相減損法)和(輾轉相除法)

#include<stdio.h> #include <math.h> /* 編寫一個函數,傳入a,b兩個int類型的變量,返回兩個值的最大公約數。 例如:輸入傳入(0 , 5)函數返回5,傳入(10 , 9)函數返回1,傳入(12

原创 【C語言】數字的字符串轉化爲 數字

#include <stdio.h> /*這個字符串參數必須包含一個或者多個數字,函數應該把這些數字字符轉換爲整數並返回這個整數。 如果字符串參數包

原创 【數據結構】順序表seqlist

#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct SeqlistNode { int date; }seqlistNode; typ

原创 【C語言】將一個數字字符串轉換成這個字符串對應的數字(包括正浮點數、負浮點數)

#include <stdio.h> /* 編寫一個函數,將一個數字字符串轉換成這個字符串對應的數字(包括正浮點數、負浮點數) 例如:"12.34" 返回12.34 "-123.34" 返回-123.34 函數原型:double m

原创 【數據結構】鏈式棧

#include <stdio.h> #include <stdlib.h> typedef struct LinkStack { int info; struct LinkStack *next; }StackNode; ty

原创 【數據結構】哈夫曼樹實現編碼譯碼

       根據一段字符串中字符的個數 作爲該字符的權值生成哈夫曼樹。        然後根據生成的哈夫曼編碼,對任意字符串實現編碼,對任意二進制串實現譯碼。 程序運行結果: 1.程序主界面: 2.根據字符串 創建哈夫曼樹及編碼:

原创 【C語言】逆轉二進制數的幾種方法

比如輸入10(1010) 輸出 5(101) 代碼有三種: 最笨的方法循環: int fuc(int x) { int count=0; int num=0; int n=x; while(n!=0) { n/=2;

原创 【數據結構】鏈式隊列

//linkqueue.h#include "stdio.h" #include "stdlib.h" #include <string.h> #define MAXSZIE 30 struct qNode { char name[MA

原创 【C語言】遞歸函數DigitSum(n)

//寫一個遞歸函數DigitSum(n),輸入一個非負整數,返回組成它的數字之和, //例如,調用DigitSum(1729),則應該返回1+7+2+9,它的和是19 #include <stdio.h> int fuc(int x)

原创 【C語言】9的個數

輸出100以內 9的個數。 循環寫法: int fuc2() { int num=1; int x,count=0; while(num<100) { x=num; while(x!=0) { if(x%10==9)

原创 【C語言】編寫一個函數實現n^k,使用遞歸實現

#include <stdio.h> int fuc(int x,int n) { if(n!=1) return x*fuc(x,n-1); return 1; } int main() { printf("%d\n"

原创 【c語言】實現Strcat函數

實現char * my_strcat(char * dest,char *src)函數. 返回: dest字符串的地址。 功能:將src指向的字符串追加到dest指向字符串的後面。 例如:char dest[10] = "andef";

原创 【c語言】實現翻轉字符串函數reverse_string

函數reverse_string(char * string) 實現:將參數字符串中的字符反向排列。 要求:不能使用C函數庫中的字符串操作函數。 #include <stdio.h> #include<stdlib.h> #define

原创 【C語言】reverse_string(char * string)(遞歸實現)

遞歸實現reverse_string(char * string)函數。 翻轉 原來的字符串 是改變  不是打印出來。 /* 編寫一個函數reverse_string(char * string)(遞歸實現) 實現:將參數字符串中的字符