關於c 一道程式設計題,見下圖,一道C 程式設計題

2021-08-09 19:17:53 字數 2577 閱讀 8370

1樓:黑丶雨

#include

#include

class mystring

;char *str;

size_type thesize;

size_type maxsize;

public:

mystring() : str(nullptr), thesize(0), maxsize(0){}

mystring(const char *s);

mystring(const mystring &s);

mystring(mystring &&s);  //移動建構函式(c++11);

mystring operator+(const mystring &s);

mystring &operator=(const mystring &s);

mystring &operator=(mystring &&s);  //移動賦值函式(c++11);

void set_str(const char *s);

friend std::ostream &operator<<(std::ostream &out, mystring &s);

size_type get_length() const

~mystring()

};mystring::mystring(const char *s)

mystring::mystring(const mystring &s)

mystring::mystring(mystring &&s)

mystring mystring::operator+(const mystring &s)

mystring &mystring::operator=(const mystring &s)

mystring &mystring::operator=(mystring &&s)

void mystring::set_str(const char *s)

std::ostream &operator<<(std::ostream &out, mystring &s)

int main()

2樓:

#include

#include

#include

#include

#include

using namespace std;

int  main()

;char s2[100]=,s3[100];

strcat(s1,s2);

strcpy(s3,s1);

cout<

3樓:

你這是要自定義一個類嗎?

一道c++程式設計題

4樓:

看了介面有返回值,就不敢直接動輸入

用了複製和記憶體釋放,然而我想多了...

#include

char *fun(char *str)

for(i=0;i %s",str,text);

free(text);

return 0;

}ggoi romndno => good morningprocess returned 0 (0x0)   execution time : 0.019 s

press any key to continue.

5樓:聽不清啊

#include

int main()

{int i,j;

char c,s[200];

gets(s);

for(j=0;s[j];j++);

if(j%2==0)j--;

for(i=1;i

6樓:

//#include "stdafx.h"//if the vc++6.0, with this line.

#include

using namespace std;

char *fun(char *str){int i,j;

for(j=0;str[j];j++);

--j = j&1 ? j : j-1;

for(i=1;i

執行結果:

7樓:麼誒節奏

#include

using namespace std;

int search(int* p1, int n, int* p2);

void print(int* p, int n);

int main()

;int arr2 = ;

int count = search(arr1, 10, arr2);

print(arr1, 10);

print(arr2, count);

system("pause");

}int search(int* p1, int n, int* p2)

}return result;

}void print(int* p, int n)cout << endl;}

一道C程式設計題一道C程式設計題

include using namespace std class dif dif int lw,int hi 建構函式,用引數lw和hi分別初始化low和high int isdiff int y void process void show int dif isdiff int y 判斷引數y的...

求解一道C語言程式設計題目,求一道C語言程式設計題

說一下思想 先定義乙個int min 1000000 或者其他大於4的數,因為陣列 專最大就4,按行屬列遍歷陣列所有元素,min min a i j a i j min 輸出的min即為所求 include define n 2 int getmin int a n int m,int n int ...

一道C語言程式設計題求解一道簡單的C語言程式設計題

樓主,抄樓上不太會說話,不要理,bai等等我貼出 沒有其他語言基礎du的c語言初學者起zhi步是慢了一dao點,但是要渣油 include int main return 0 dim arr斐波 那契數bai 列du 19 as integer arr斐波那 zhi契數dao列回 答 0 1 arr...