4点起步C++(第四集)

本集的主要内容,简单程序设计

1.输出 Good Moring 和Welcome to China!

#include <iostream>
using namespace std;
int main()
{
    cout<<"Good Moring!"<<endl;
    cout<<"Welcome to China!"<<endl;
    return 0;
}

运行
在这里插入图片描述


2.求出下列数据类型,表达式火变量在内存中占的字节的大小。
1). int , short, float, double, int*, double*, int**;
2). 2.5+8+‘A’, float(5+2.0);
3).int i[10]; float f [10]; char s [ ]=“str”;

#include <iostream>
using namespace std;
int main()
{
    cout<<"The size of int is:"<<sizeof(int)<<endl;
    cout<<"The size of short is:"<<sizeof(short)<<endl;
    cout<<"The size of float is:"<<sizeof(float)<<endl;
    cout<<"The size of int* is:"<<sizeof(int*)<<endl;
    cout<<"The size of double* is:"<<sizeof(double*)<<endl;
    cout<<"The size of int** is:"<<sizeof(int**)<<endl;
    cout<<"The size of 2.5+8+'A' is:"<<sizeof(2.5+8+'A')<<endl;
    cout<<"The size of float(5+2.0) is:"<<sizeof(float(5+2.0))<<endl;
    int i[10];
    cout<<"The size of i[10] is :"<<sizeof(i)<<endl;
    char s[]="Hello World";
    char *p = "Hello World";
    cout<<"The size of s is:"<<sizeof(s)<<endl;
    cout<<"The size of *p is:"<<sizeof(p)<<endl;
    return 0;
}

运行

在这里插入图片描述


3.简单计算器

#include <iostream>
using namespace std;
int main()
{
    double a,b,result;
    char c;
    int flag=0;
    cout<<"Input a number:";
    cin>>a;
    cout<<"choose calculate type:";
    cin>>c;
    cout<<"Input other number:";
    cin>>b;
    switch(c)
    {
        case'+':result = a+b;break;
        case'-':result = a-b;break;
        case'*':result = a*b;break;
        case'/':result = a/b;break;
        default : flag=1;
    }
    if(flag==1||((c=='/')&&(b==0)))
        cout<<"Iuput is wrong!";
    else
        cout<<a<<c<<b<<"=:"<<result<<endl;
    return 0;
}

4.求s(n)=1! - 2! + 3! - 4! + 5!.. n!的值

#include <iostream>
using namespace std;
int main()
{
    int fac = 1,sum=0;
    int i,k,n;
    cin>>n;
    for(i=1,k=1;i<=n;i++){
        fac=fac*i;
        sum+=k*fac;
        k=-1*k;
    }
    cout<<"sum="<<sum<<endl;
    return 0;
}

示例:输入数字3

在这里插入图片描述


5.一个10X10的方阵,每个格子里的数字的值是它所在的行值与列值相乘的结果,求出阴影部分的数值的乘积,非阴影部分的和。
在这里插入图片描述

#include <iostream>
using namespace std;
int main()
{
   double result1=1,result2=0;
   for(int i=1;i<=10;i++){
    for(int j=1;j<=10;++j){
        if(((i>=1)&&(i<=4))&&((j>=1)&&(j<=7))
           ||((i>=7)&&(i<=9))&&((j>=7)&&(j<=9)))
           result1 = result1*i*j;
           else
           result2 = result2+i*j;
    }
   }
   cout<<"The product is :"<<result1<<endl;
   cout<<"The sum is:"<<result2<<endl;
    return 0;
}

运行

在这里插入图片描述

Fiberhome S5800系列三层千兆路由交换机操作手册是一本详细介绍如何使用这款路由交换机的指南。这款路由交换机是一种高性能的网络设备,用于在网络中传输数据包。操作手册提供了用户使用路由交换机的详细步骤、设置方法和注意事项等信息。 操作手册首先介绍了S5800系列路由交换机的硬件组成和功能特点。这包括路由交换机的外观、端口、指示灯等基本信息,以及交换机的三层路由、千兆传输速率等主要功能。用户可以通过了解这些硬件配置和功能特点,更好地使用路由交换机。 接下来,操作手册详细介绍了路由交换机的安装和连接方式。用户可以根据手册中的步骤,将路由交换机连接到网络中,并确保连接的稳定性和正确性。 然后,手册讲解了路由交换机的设置和配置方法。用户可以按照操作手册中的指导,登录到路由交换机的管理界面,进各项设置,如IP地址分配、接口配置、路由协议设置等。手册还提供了一些常见问题的解答和故障处理方法,帮助用户解决使用中遇到的问题。 最后,操作手册介绍了路由交换机的管理和维护方法。用户可以了解如何对交换机配置备份和恢复,如何进固件升级和性能监控等。手册还提供了一些常见故障排除方法和维护建议,以帮助用户保持交换机的正常运。 总之,Fiberhome S5800系列三层千兆路由交换机操作手册是一本对于用户使用这款路由交换机非常有帮助的指南。通过学习本手册,用户可以全面了解该路由交换机的功能和配置,高效地使用和管理该设备,进而提升网络传输的性能和可靠性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值