用博客记录充实的beautiful life~

C++ Primer plus 

P35 NO 1

#include<iostream>
using namespace std;
int main()
{
	cout<<"我叫LYY,以后一定在沿海的城市!"<<endl;
	return 0;
}
下面是借鉴别人的 一个学长吧 感觉很牛逼的样子诶  但是 cin.get()是什么功能??

  1. #include <iostream.h>  
  2. int main()  
  3. {  
  4.   cout<<"我的名字啊,这是个什么啊"<<endl;  
  5.   cout<<"我家住在黄土高坡\n";  
  6.   cin.get();  
  7.   return 0;      
  8.       
cin.get() 这个是从输入流中获取一个字符,所以下这句时,当程序运行到这里的时候,因为输入流中没有字符可以获取,需要你输入一个字符,所以你输入个回车程序就会结束
NO 2   英语真是太差了!!!long 是关键字时保留字,不能用来做变量,所以改成longa,码用yard比较好

#include<iostream>
using namespace std;
int main()
{
	int longa,ma;
	cout<<"please enter a distance !"<<endl;
	cin>>longa;
	ma=longa*220;
	cout<<"距离为"<<longa<<" long等于 "<<ma<<"码。"<<endl;
	return 0;
}
还是再看了一下别人的 用了两次cin.get(), 试了一下用一次好像也可以,还是不知道为什么
#include <iostream.h>  
int main()  
{  
 cout<<"输入一个以码为单位的距离\n";  
 int n;  
 cin>>n;  
 //cout<<n;  
 cout<<"转换之后啊,看看是多少啊:\n"<<n*220<<"码"<<endl;   
 //cin.get();  
 cin.get();  
 return 0;
}  

NO 3 这道还好啦! 忘了函数声明  ,MinGW都提醒我了~记得 先声明 再调用 再写函数定义呀功能什么的

#include<iostream>
using namespace std;
void mice();
void run();
int main()
{
	int i;
	for(i=0;i<2;i++)
		mice();
	for(i=0;i<2;i++)
		run();
	return 0;
}
void mice()
{
	cout<<"Three blind mice."<<endl;
}
void run()
{
	cout<<"See how they run."<<endl;
}

不用看别人的了 我对自己很满意 虽然对看这篇文章的你来说可能是个笑话嘿嘿!!去跑步啦!!

猜你喜欢

转载自blog.csdn.net/lyycasablanca000/article/details/39402555