原创 C語言編程 產生一個隨機數

利用rand()函數來返回一個一隨機數值,範圍在0至RAND_MAX間。 返回0至RAND_MAX之間的隨機數值,RAND_MAX定義在stdlib.h,(其值至少爲32767)。 具體要看定義的變量類型,int整型的話就是32767。 此

原创 C語言數據結構 單鏈表及其基本功能實現

頭文件如下: #ifndef _SLIST_H_ #define _SLIST_H_ typedef int SLTDataType; typedef struct SListNode { SLTDataType data;

原创 C語言數據結構 線性表的基本功能實現

頭文件如下 #ifndef _SEQLIST_H_ #define _SEQLIST_H_ // 順序表的動態存儲 #include <stdio.h> #include <stdlib.h> #include <string.h> t

原创 C語言數據結構 鏈表總結

單向鏈表(無頭無循環)1.頭插 cur->next=head; head=cur; 2.後插 cur->next=pos->next; pos->next=cur; 3.頭刪 tmp=head->next; free(head); head

原创 C語言數據結構 雙向鏈表以及基本功能實現

項目頭文件: #ifndef _LIST_H_ #define _LIST_H_ #include <stdio.h> #include<stdlib.h> typedef int LTDataType; typedef struct L

原创 C語言 strchr的實現

#include<stdio.h> #include<stdlib.h> #include<string.h> char *mystrchr(char *str, char c) { int i; for (i = 0; i

原创 C語言 strcpy的實現

#include<stdio.h> #include<stdlib.h> void mystr(char *arr2, char *arr1,int length) { int i; for (i = 0; i < leng

原创 JAVA 三角形類Triangle(GeometricObject繼承)

package triangletest; import java.util.*; public class TriangleTest{ public static void main(String args[]){ Scanner s

原创 C語言 strcat的實現

#include<stdio.h> #include<stdlib.h> #include<string.h> void mystrcat(char *arr1, char *arr2,int leng) { int i=1,m=0

原创 C語言 strcmp的實現

#include<stdio.h> #include<stdlib.h> int mystrcmp(char* str1, char* str2) { for (;*str1!='\0' ;str1++,str2++) {

原创 C語言 memcpy的實現

#include<stdio.h> #include<stdlib.h> void mymemcpy(char *str1, char *str2, int k) { int i; for (i = 0; i < k; i+

原创 C語言 strstr的實現

#include<stdio.h> #include<stdlib.h> #include<string.h> char *mystrstr(const char *str1,const char *str2) { int i =

原创 C語言編程 數列中找出兩個只出現一次的數

原題:一個數組中只有兩個數字是出現一次,其他所有數字都出現了兩次。找出這兩個只出現一次的數字,編程實現。 此題要用到在數列中找出只出現一次的一個數字的方法參考https://blog.51cto.com/14232799/2382172 此

原创 C語言編程 找出數列中只出現一次的兩個數

原題:一個數組中只有兩個數字是出現一次,其他所有數字都出現了兩次。找出這兩個只出現一次的數字,編程實現。 此題要用到在數列中找出只出現一次的一個數字的方法參考https://blog.51cto.com/14232799/2382172 此

原创 JAVA編程練習 創建風扇對象(開關 風速等)

自帶測試類源代碼: public class TestFan { public static void main(String[] args) { Fan o1=new Fan(); Fan o2=new Fan()