07.04C

【项目2:转着圈加密】
为使电文保密,往往按一定规律将电文转换成密码,收报人再按约定的规律将其译回原文。
加密办法,如图所示,每一个字母的密文是其后第4个字母,若超出了字母的范围,将A看作为Z的下一个字母,将a看作是z的下一个字线,依次顺延。

如″Wonderful!″转换为″Asrhivjyp!″。
输入一行字符,要求输出其相应的密码。

解法:

#include <stdio.h>
int main( )
{
    char c;
    while ((c=getchar( ))!='\n')
    {
        if((c>='a'&&c<='z')|| (c>='A'&&c<='Z'))
        {
            c=c+4;
            if((c>'Z' && c<='Z'+4) || (c>'z'))
                c=c-26;
        }
        putchar(c);
    }
    printf("\n");
    return 0;

【项目5:有多少符号】
输入一行文字,以回车结束,统计并输出其中数字、空格、字母出现的次数,以及输入的字符总数。

解法:

#include <stdio.h>
#include <stdlib.h>


int main()
{
    int a=0,b=0,c=0,i=0;
    char ch;
    printf("please enter a sentence:\n");
    while((ch=getchar())!= '\n')
    {
        if(ch >=48 && ch <= 57)
            a++;
        if(ch>=65 && ch <=90)
            b++;
        if(ch>=97 && ch <= 122)
           c++;
        ++i;
    }
    printf("the amount of number is:%d\n",a);
    printf("the amount of capital letters is:%d\n",b);
    printf("the amount of lower-case letters is:%d\n",c);
    printf("the amount of character is:%d\n",i);


    return 0;
}











































































































@j-VMware-Virtual-Platform:~$ ros2 topic info /scan --verbose Type: sensor_msgs/msg/LaserScan Publisher count: 1 Node name: rplidar_composition Node namespace: / Topic type: sensor_msgs/msg/LaserScan Topic type hash: RIHS01_64c191398013af96509d518dac71d5164f9382553fce5c1f8cca5be7924bd828 Endpoint type: PUBLISHER GID: 01.0f.54.ad.4b.0e.81.e6.00.00.00.00.00.00.14.03 QoS profile: Reliability: RELIABLE History (Depth): UNKNOWN Durability: VOLATILE Lifespan: Infinite Deadline: Infinite Liveliness: AUTOMATIC Liveliness lease duration: Infinite Subscription count: 2 Node name: _ros2cli_3699 Node namespace: / Topic type: sensor_msgs/msg/LaserScan Topic type hash: RIHS01_64c191398013af96509d518dac71d5164f9382553fce5c1f8cca5be7924bd828 Endpoint type: SUBSCRIPTION GID: 01.0f.54.ad.73.0e.fd.6e.00.00.00.00.00.00.07.04 QoS profile: Reliability: RELIABLE History (Depth): UNKNOWN Durability: VOLATILE Lifespan: Infinite Deadline: Infinite Liveliness: AUTOMATIC Liveliness lease duration: Infinite Node name: slam_toolbox Node namespace: / Topic type: sensor_msgs/msg/LaserScan Topic type hash: RIHS01_64c191398013af96509d518dac71d5164f9382553fce5c1f8cca5be7924bd828 Endpoint type: SUBSCRIPTION GID: 01.0f.54.ad.ba.0e.b0.e5.00.00.00.00.00.00.44.04 QoS profile: Reliability: BEST_EFFORT History (Depth): UNKNOWN Durability: VOLATILE Lifespan: Infinite Deadline: Infinite Liveliness: AUTOMATIC Liveliness lease duration: Infinite j@j-VMware-Virtual-Platform:~$ @j-VMware-Virtual-Platform:~$ ros2 topic list /clock /map /map_metadata /parameter_events /pose /rosout /scan /slam_toolbox/feedback /slam_toolbox/graph_visualization /slam_toolbox/scan_visualization /slam_toolbox/transition_event /slam_toolbox/update /tf /tf_static j@j-VMware-Virtual-Platform:~$ ros2 topic echo /map --no-arr
最新发布
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值