原创 c語言編寫猜數小遊戲

#define _CRT_SECURE_NO_WARNINGS 1 #include "stdio.h" #include <stdlib.h> #include <time.h> void menu() { <span style=

原创 C語言編寫代碼,演示多個字符從兩端移動,向中間匯聚

#include "stdio.h" #include "string.h" #include "windows.h" int main() { char arr1[] = { "welcome to china!" }; char

原创 C語言打印1000-2000年裏的閏年

</pre><pre name="code" class="cpp"> 1. <pre name="code" class="cpp">#include "stdio.h" int main() { int year = 0; i

原创 C語言 模擬實現strcmp strncmp

strcmp的作用是利用ASCII值比較兩個字符串的大小 兩個字符串str1,str2,若str1>str2,則返回一個大於0的正數,若str1<str2,則返回一個小於0的負數,若相等,則返回0 #include <stdio.h> #

原创 模擬實現strcpy strncpy

strcpy的作用是將一個字符串的內容複製到另外一個字符數組中,包括字符串的終結符 #include <stdio.h> #include<assert.h> #include<Windows.h> char * my_strcpy(c

原创 C語言不創建臨時變量,交換兩個整型的值

第一種方法, 異或 #include "stdio.h" int main() { int a = 0; int b = 0; scanf("%d%d",&a,&b); a = a^b; b = a^b; a = a^b;

原创 C語言打印九九乘法表

</pre><pre name="code" class="cpp">#include "stdio.h" int main() { int i, j; for (i = 1; i <= 9; i++) for

原创 C語言 編寫登錄系統

#define _CRT_SECURE_NO_WARNINGS 1 #include "stdio.h" #include"string.h" int main() { int i = 0; char password[10] =

原创 C語言 打印圖案

#define _CRT_SECURE_NO_WARNINGS 1 #include"stdio.h" int main() { int lines = 0; printf("Please enter the lines:");

原创 C語言實現三子棋

三子棋的實現是當玩家或者電腦下的位置連成線時即可判斷爲贏。 在編寫時要注意到 (1)每次玩家或者電腦玩之後都要打印一次棋盤 (2)每次下一步棋,打印棋盤後,都要判斷是否已經贏了 (3)判斷輸贏之後判斷棋盤是否已 滿 (4)電腦是隨機的位置

原创 預處理標識符: __LINE__ __FILE__ __DATE__ __TIME__ ##

1.__LINE__ 在LINE前後各有兩個下劃線。LINE的用途是打印當前行的行號 #include <stdio.h> int main() { printf("%d\n", __LINE__); system("pause")

原创 C語言 獲取一個數二進制序列中所有的偶數位和奇數位,分別輸出二進制序列

#define _CRT_SECURE_NO_WARNINGS 1 #include "stdio.h" int main() { int num = 10; int i = 0; printf("Please enter the

原创 C語言編寫掃雷小遊戲

掃雷遊戲 當選擇的位置不是雷時,該位置顯示周圍的雷的數目,踩到雷則遊戲結束 頭文件mine.h #ifndef _MINE_H_ #define _MINE_H_ #define ROWS 9 #define COLS 9 #defi

原创 select

select用於探測多個句柄狀態的變化 #include <sys/select.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> in

原创 Shell腳本中反引號`和$()的區別

`和()都是命令替換符。由反引號括起來的也是⼀條命令,Shell先執⾏該命令,然後將輸出結果⽴刻代換到當前命令⾏中。命令代換也可以⽤ ()表⽰: DATE=(date) (())⽤於算術計算,(())中的Shell變量取值將轉換成整數,例