C++ Primer练习题day1

/*
练习1.1略
练习1.2.改写程序,让他返回-1.
练习1.3.编写程序,在标准的输出上打印Hello,World。
*/
#include<iostream>
int main()
{
    std::cout<<"Hello,World"<<std::endl;
    return 0;
}
/*
练习1.4.编写程序使用乘法运算符来打印两个数的积
练习1.5
*/
#include<iostream>
int main()
{
    std::cout<<"Please input two numbers:"<<std::endl;
    int v1,v2;
    std::cin>>v1>>v2;
    std::cout<<v1<<" * "<<v2<<" = "<<v1*v2<<std::endl;
    return 0;
}
/*练习1.6.解释程序是否合法*/
std::cout<<"The sum of "<<v1;
    <<" and "<<v2;
    <<<" is "<<v1+v2<<std::endl;
/*
代码不合法,缺少相应的std::cout
*/

猜你喜欢

转载自www.cnblogs.com/congrifan/p/11261812.html