⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s2.cpp

📁 这是清华大学出版社的《数据结构》的电子文档讲义
💻 CPP
字号:
// s2.cpp : Defines the entry point for the console application.
//

# include "stdafx.h"
# include "array.h"		//包含向量类的头文件,

int main(int argc, char * argv[]){
	int a[10] = {1,12,-14,4,0,5,-8,16,0,7};
	array<double> s1(10);
	for(unsigned j=0; j<s1.length(); j++) cout<<s1[j]<<",  ";
	cout<<endl;									//10个随机数
	int k=0;
	for(j=0; j<10; j++){
		if(a[j]>1) s1[k++] = a[j]*2.0+1.5;}
	for( j=0; j<s1.length(); j++)
		cout<<s1[j]<<",  ";						//25.5,9.5,11.5,33.5,15.5,5个随机数
	cout<<endl<<endl;
	s1.reSize(k-2);	
	for( j=0; j<s1.length(); j++) cout<<s1[j]<<",  ";
	cout<<endl<<endl;							//25.5,9.5,11.5,
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -