C++入门经典第二章第二节自测题

8

#include "stdafx.h"
#include <iostream> 
using namespace std; 
int main()
{
    cout << "The answer to the question of\nLife,the Universe,and Everything is 42";
}

9

#include "stdafx.h"
#include <iostream> 
using namespace std; 
int main()
{
    int the_number;
    cout << "请输入一个整数:\n";
    cin >>the_number;
    cout <<the_number;
}

10

#include "stdafx.h"
#include <iostream> 
using namespace std; 
int main()
{
    double the_number=9.6;
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(3);
    cout <<the_number;
}

11

#include "stdafx.h"
#include <iostream> 
using namespace std; 
int main()
{
    cout <<"Hello World";
}

12

#include "stdafx.h"
#include <iostream> 
using namespace std; 
int main()
{
    int a,b;
    cout <<"请输入两位整数:\n";
    cin >> a>>b;
    cout <<"两者之和为:"<<a+b;
}

13

#include "stdafx.h"
#include <iostream> 
using namespace std; 
int main()
{
    cout <<"请输入\n两位整数:"<<endl;
    cout <<"请输入\t两位整数:";
}

14

#include "stdafx.h"
#include <iostream> 
using namespace std; 
int main()
{
    double a=1,b=1.414,c=1.732,d=2,e=2.236;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(4);
cout<<"N\tSqure Root"<<endl;
cout<<"1\ta"<<endl;
cout<<"2\tb"<<endl;
cout<<"3\tc"<<endl;
cout<<"4\td"<<endl;
cout<<"5\te"<<endl;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值