真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

c++primerpluschapter8習(xí)題-創(chuàng)新互聯(lián)

在這里插入圖片描述

成都服務(wù)器托管,創(chuàng)新互聯(lián)建站提供包括服務(wù)器租用、光華機(jī)房服務(wù)器托管、帶寬租用、云主機(jī)、機(jī)柜租用、主機(jī)租用托管、CDN網(wǎng)站加速、空間域名等業(yè)務(wù)的一體化完整服務(wù)。電話咨詢(xún):18982081108
#include#includeusing namespace std;

const int SIZE = 30;

struct CandyBar {char brand[SIZE];
	double weight;
	int heat;
};

void set_CandyBar(CandyBar& c, const char* str = "Millenniu Munch", const double w = 3.46, const int h = 340);
void show(const CandyBar& c);

int main() {CandyBar candy;
	set_CandyBar(candy, "xiaobaitu", 5.56, 180);
	show(candy);
	return 0;
}

void set_CandyBar(CandyBar& c, const char* str, const double w, const int h)
{strcpy_s(c.brand, str);
	c.weight = w;
	c.heat = h;
}

void show(const CandyBar& c)
{cout<< "Brand:"<< c.brand<< endl;
	cout<< "Weight:"<< c.weight<< endl;
	cout<< "Heat:"<< c.heat<< endl;
}

在這里插入圖片描述

#include#include#includeusing namespace std;

void Toupper(string &str);

int main() {string str;
	cout<< "Enter a string (q to quit):";
	getline(cin, str);
	while (str != "q") {Toupper(str);
		cout<< str<< endl;
		cout<< "Next string(q to quit):";
		getline(cin, str);
	}
	cout<< "Byebye!"<< endl;
	return 0;
}

void Toupper(string& str)
{for (int i = 0; i< str.size(); i++) {str[i] = toupper(str[i]);
	}
}

在這里插入圖片描述

#include#include#includeusing namespace std;

struct stringy {char* str;
	int ct;
};

void set(stringy& str, const char* ch);
void show(const stringy& str, int n = 1);
void show(const char* ch, int n = 1);


int main() {stringy beany;
	char testing[] = "Reality isn't what it used to be.";
	set(beany, testing);
	show(beany);
	show(beany, 2);
	testing[0] = 'D';
	testing[1] = 'u';
	show(testing);
	show(testing, 3);
	show("Done!");
	return 0;
}

void set(stringy& str, const char* ch) {int num = strlen(ch) + 1;
	str.str = new char[num];
	strcpy_s(str.str, num, ch);
	str.ct = strlen(str.str);
}

void show(const stringy& str, int n) {for (int i = 0; i< n; i++) {cout<< str.str<< " "<< str.ct<< endl;
	}
}

void show(const char* ch, int n) {for (int i = 0; i< n; i++)
		cout<< ch<< endl;
}

在這里插入圖片描述

#includeusing namespace std;

templateT max5(T num[]);


int main() {int num1[5] = {5, 8, 4, 9, 6 };
	double num2[5] = {5.3, 4.8, 3.9, 10.8, 1.2 };
	cout<< max5(num1)<< endl;
	cout<< max5(num2)<< endl;
	return 0;
}

templateT max5(T num[]) {T max = num[0];
	for (int i = 1; i< 5; i++) {if (num[i] >max) {	max = num[i];
		}
	}
	return max;
}

在這里插入圖片描述

#include#includeusing namespace std;

templateT max5(T num[], int n);

template<>char* max5(char* ch[], int n);

int main() {int num1[6] = {5, 8, 4, 9, 6, 16 };
	double num2[4] = {5.3, 4.8, 3.9, 10.8 };
	const char* ch[5] = {"Nice to meet you.", "I love you,Rick.", "Go away.", "Good grief.", "Good moring" };
	cout<< max5(num1, 6)<< endl;
	cout<< max5(num2, 4)<< endl;
	cout<< max5(ch, 5)<< endl;
	return 0;
}

templateT max5(T num[], int n) {T max = num[0];
	for (int i = 1; i< n; i++) {if (num[i] >max) {	max = num[i];
		}
	}
	return max;
}

template<>char* max5(char* ch[], int n) {int pos = 0;
	for (int i = 1; i< n; i++) {if (strlen(ch[i]) >strlen(ch[pos])) {	pos = i;
		}
	}
	return ch[pos];
}

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧


文章題目:c++primerpluschapter8習(xí)題-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)地址:http://weahome.cn/article/gicji.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部