一个使用IO库的程序
#include<iostream>
int main(void)
{
std::cout <<"Enter two numbers:"<<std::endl;
int v1=0, v2=0;
std::cin >> v1 >> v2;
std::cout<< "The sum of " << v1 << "and" << v2 <<"is"
<<v1+v2<<std::endl;
return 0;
}
/*练习1.4.3
******************Windows输入文件结束符 ctrl+Z
#include <iostream>
int main(void)
{
int sum = 0, val = 0;
while(std::cin >> val)
{
sum += val;
}
std::cout << sum;
return 0;
}*/
/*练习1.4.4 Input一串数字 统计连续出现的次数
*******************
int main(void)
{
int vr = 0, val = 0;
if(std::cin >> vr)
{
int time = 1;
while(std::cin >> val)
{
if(vr == val)
{
++time;
}
else
{
std::cout << vr << "出现的次数是" << time <<std::endl;
vr=val;
time=1;
}
}
std::cout << vr << "出现的次数是" << time << std::endl;
}
return 0;
}*/
/*************
****************这个是加一个类的头文件 添加失败 不知道添加到哪个文件工作目录下 -----------疑问-------------
#include <iostream>
#include "Sales_item.h"
#include "Version_test.h"
int main(void)
{
Sales_item book;
std::cin >> book;
std::cout << book >> std::endl;
return 0;
}
*/
#include <iostream>
int reand = 42;
int main(void)
{
int nuique = 0;
std::cout<< reand << " "<< nuique<< std::endl;
int reand = 0;
std::cout<< reand << " "<< nuique << std::endl;
std::cout<< ::reand<< " "<< nuique << std::endl;
return 0;
}
#include <iostream>
int main(void)
{
const int &const r2= 3;
double pi=3.141956;
const double *const pip= π
return 0;
}
//练习5.14 读取一串字符 计算其中重复出现的次数
/*#include <iostream>
using namespace std;
int main(void)
{
string Beforeword, Nowword, Resultword;
int cnt=0, maxcnt=1;
while(cin>> Nowword)
{
if(Beforeword == Nowword)
{
++cnt;
}
else
{
if(cnt > maxcnt)
{
maxcnt = cnt;
Resultword = Beforeword;
}
cnt = 1;
}
Beforeword = Nowword;
}
if(maxcnt != 1)
{
cout<< Resultword <<endl<< maxcnt;
}
return 0;
}*/