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

📄 cpp1.cpp

📁 面向对象的程序设计:数据结构<向量类实现优先队列>
💻 CPP
字号:
#include<iostream.h>
#include<string.h>
void print(char *s);
void main()
{
	//cout

	cout<<'k'<<'a'<<'n'<<'g'<<endl;
	cout.put('k').put('a').put('n').put('g').put('\n');
	char c1='k', c2='a', c3='n', c4='g';
	cout.put(c1).put(c2).put(c3).put(c4).put('\n');
	char *str="I love you kang .";
	cout<<"The string is \""<<str<<"\""<<endl;//由于是双斜线出现在字符数组中 ,而它又使定界符,故用反斜线\" 表示
	print(str);

	//cin2 getline() find the Input max strings 
	static const int SIZE=80;
	char buf[SIZE];
	int lcnt=0,lmax=-1;
	cout<<"Input ...\n";
	while(cin.getline(buf,SIZE))
	{
		int count= cin.gcount();//该函数的功能是返回上一次从输入流中实际读取的字符个数,包含空白符 
		lcnt++;
			if(count>lmax)
				lmax=count;
			cout<<"Line #"<<lcnt<<':'<<'\t'<<count<<endl;
			cout.write(buf,count).put('\n').put('\n');
	}
	cout<<endl;
	cout<<"Longest line:"<<lmax<<endl;
	cout<<"Total line:"<<lcnt<<endl;
//cin3
	char ch;
	cout<<"Enter characters:";
	while((ch=cin.get())!=EOF||ch=='\n')
		cout.put(ch).put('\t');

	//cin
	
	static const int N=40;
	char s1[N],
		 s2[N];
	cout<<"Enter a strings:"<<endl;
	cin>>s1;
	cout<<"s1="<<s1<<endl;
	cin.get(s2,N);
	cout<<"s2 = "<<s2<<endl; 
	

}
void print(char *s)
{
	cout.write(s,strlen(s)).put('\n');
	cout.write(s,6)<<'\n';
}

⌨️ 快捷键说明

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