Time of Update: 2018-12-03
12-3 代碼 /*服務端*/#include<sys/types.h>#include<sys/socket.h>#include<string.h>#include<sys/unistd.h>#include<netinet/in.h>#define MAXSIZE 80#define MYPORT 3490#define BACKLOG 10#define BUFSIZE 100 void main(){ int
Time of Update: 2018-12-03
1.
Time of Update: 2018-12-03
1、在cpp檔案中調用c檔案中實現的函數的時候,需要用extern "C"聲明該函數,否則cpp會按名字改編後的函數名去找該函數而找不到。(這是作用) c檔案中有一函數: void Transfer(int a; char b); cpp檔案中必須用extern "C"聲明該函數如下才可以實行調用: extern "C" void Transfer(int a; char
Time of Update: 2018-12-03
1、使用指標完成以下內容:定義三個整數的的列陣,寫三個功能,input(),deal(),print():輸入,處理,列印:input功能,需要完成三個編號的輸入,deal功能需要從小到大排序,print功能需要列印結果。我的思路:首先定義一個整數的數組,長度為3;然後分別輸入,再處理排序,用排序方法排序,最後輸出結果;實現代碼:主函數裡就定義四行代碼 : int a[3]; input(a); deal(a); print(a);分別實現的方法:void
Time of Update: 2018-12-03
第一個關鍵字:auto 用來聲明自動變數。 可以顯式的聲明變數為自動變數。只要不是聲明在所有函數之前的變數,即使沒加auto關鍵字,也預設為自動變數。並且只在聲明它的函數內有效。而且當使用完畢後,它的值會自動還原為最初所賦的值。自動變數使用時要先賦值,因為其中包含的是未知的值。例:auto int
Time of Update: 2018-12-03
//=====================================================================//TITLE:// 圖文詳解如何搭建Windows的Android C++開發環境(一)//AUTHOR:// norains//DATE:// Thursday 14-April-2011//Environment:// Cygwin 1.7.9// Android NDK r5//===================
Time of Update: 2018-12-03
#include<iostream>#include<cstring> #include<stack>using namespace std;typedef struct{ int detail[3][3];}Map;int main(){ Map m,n; //利用指標進行struct結構體中數組的賦值操作 for(int i=0;i<9;i++) scanf("%d",*m.detail+i); for(int i=0;i<9;i++
Time of Update: 2018-12-03
#include<iostream>#include<queue>using namespace std;bool test; //bool變數預設的初始值為false typedef struct Node{ int a; friend bool operator<(const Node& a,const Node& b){ //定義struct結構的比較函數 if( a.a< b.a) return
Time of Update: 2018-12-03
#include<pthread.h>#include<stdio.h>#include<stdlib.h>#include<string.h>#include<semaphore.h>#include <unistd.h>#define THREAD_NUM 25typedef struct{ FILE *_fp; int _nThreadId;//第幾個線程 sem_t
Time of Update: 2018-12-03
//上機練習2//******************************************************//統計文本中單詞的個數!//******************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>void main(){char
Time of Update: 2018-12-03
//*********************************************************************************//第6題//統計每個月過生日的人數,120個人的,隨機產生這些人的生日的月份。//*********************************************************************************#include <stdio.h>#include <stdlib.
Time of Update: 2018-12-03
非C++內建型別 A 和 B,在哪幾種情況下B能隱式轉化為A?答:a. class B : public A { ……} // B公有繼承自A,可以是間接繼承的b. class B { operator A( ); } // B實現了隱式轉化為A的轉化c. class A { A( const B& ); } // A實現了non-explicit的參數為B(可以有其他帶預設值的參數)建構函式d. A& operator= ( const A& ); // 賦值操作,雖不
Time of Update: 2018-12-03
//************************************************//第8題//使用者輸入一個標示符,判斷是否為合法標示符//************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>void main(){char str[100
Time of Update: 2018-12-03
#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <string.h>void LowerString(char *str){int length = strlen(str);for(int i=0;i<length;i++){if(str[i]>='A' && str[i]<='Z'){str[i]+=32;}}}void
Time of Update: 2018-12-03
//*********************************************************************//第9題//顯示特殊矩陣//*********************************************************************#include <stdio.h>#include <stdlib.h>#include <math.h>void main(){int array[6
Time of Update: 2018-12-03
//************************************************//第10題//35名學生,每名學生4門課程,隨機產生,計算平均成績,按平均成績排名排名//************************************************#include <stdio.h>#include <stdlib.h>#include <time.h>#define NUM 10void main(){int
Time of Update: 2018-12-03
string類預設產生的函數有哪些?預設建構函式解構函式拷貝建構函式賦值建構函式 具體實現如下:#include <iostream>using namespace std;class mystring{friend ostream &operator<<(ostream &out,const mystring &s);public:mystring(const char *str=NULL);mystring(const mystring
Time of Update: 2018-12-03
#include <stdio.h>#include <string.h>char *bxy_strstr(const char *s1, const char *s2) {int len2; if (!(len2 = strlen(s2))) {return (char *)s1; }for ( ;*s1; ++s1) { if (*s1==*s2 && strncmp( s1, s2, len2 ) == 0) {return (char *)s1;}
Time of Update: 2018-12-03
#include <iostream>using namespace std; class B {public:int i, j;B(int x = 999) :j(x),i(j){cout << "B::B() invoked\n" << endl;} ~B(){cout << "B::~B() invoked\n" << endl;}};class D : public B {public:D() {cout <<
Time of Update: 2018-12-03
#include <iostream>#include <string>using namespace std;class Fruit{private:string name;string colour;public:friend istream &operator >> (istream &,Fruit &);friend ostream &operator << (ostream &,const