原创 c語言棋盤遊戲

<pre name="code" class="cpp"># include <stdio.h> void init_chessboard(char arr[3][3]); void print(char arr[3][3]); ch

原创 實現函數itob

# include <stdio.h> # include <assert.h> # include <string.h> void swap(char *p1,char *p2) { char tmp = *p1;

原创 從鍵盤接收字符並輸出對應大寫或小寫

# include <stdio.h> # include <string.h> int main() { char c = 0; while ( (c = getchar()) != EOF) {

原创 實現strstr函數

# include <stdio.h> # include <assert.h> # include <string.h> char *my_strstr(const char *str,const char *sub_str)

原创 實現一個棧,要求Push(入棧),Pop(出棧),Min(返回最小值的操作)的時間複雜度爲O(1)

問題描述:實現一個棧,要求Push(入棧),Pop(出棧),Min(返回最小值的操作)的時間複雜度爲O(1) 分析問題:要記錄從當前棧頂到棧底元素的最小值,很容易想到用一個變量,每push一個元素更新一次變量的值。那麼問題來了,

原创 進制轉換

# include <stdio.h> # include <assert.h> # include <string.h> void swap(char *p1,char *p2) { char tmp = *p1;

原创 c++日期類

用c++完成一個日期類Date,該類用於表示日期值(年、月、日),要求能實現查詢n天后的日期,兩個日期相差天數。 # include<iostream> # include<assert.h> using namespace st

原创 打印楊輝三角

# include <stdio.h> int main() { int i,j; int n = 12; int a = 1; int b[18][18] = {0}; for (i =

原创 文章標題

# include <stdio.h> # include <stdlib.h> # include <string.h> int my_strlen(char *str) { if(*str == '\0')

原创 宏與函數的不同

c/c++語言中允許使用一個標示符來表示一個字符串,稱爲宏。該字符串可以是常數、表達式、格式串等。宏與函數有時可以達到同等目的,使用宏的語法和使用函數的語法是完全一樣的,但是宏的行爲和真正的函數相比還存在一些不同的地方。 1、每

原创 找出數組中只出現一次的兩個數字

# include <stdio.h> int findFirstOne(int num) { int flag = 1; int count = 0; while (flag) {

原创 旋轉字符串

# include <stdio.h> # include <string.h> # include <assert.h> /* char *left_rorate(char *str,int n) { int i =

原创 猜拳遊戲

#include<stdio.h> #include<string.h> #include<stdlib.h> #include<time.h> #include<windows.h> //宏定義 #define NAME_SI

原创 STL空間配置器

一、STL爲什麼需要空間配置器?(內存有關) 1、解決內存碎片(外碎片) 外碎片:小塊內存頻繁分配導致小塊空間不連續,分配不出大塊的空間。 內碎片:比如需要3個字節,向上對齊取整new了8個字節,那麼這5個未使用的爲

原创 註釋轉換

將c語言的註釋轉換成c++的註釋 測試用例: 1.一般情況 /* int a = 0; */ 2.連續* /***/ 3.換行問題 /* int b = 0; */ int c = 0; /* aaa */ int d = 0; 4.匹