• 蓝桥杯省赛备战笔记——(二)字符串和日期——练习题


    例题:字符串中A的数量

    #include<stdio.h>
    #include<string.h>
    char s[105];
    int main(){
        int len, cnt = 0;
        scanf("%s",s);
        len = strlen(s);
        for(int i = 0;i < len;i++){
            if(s[i] == 'A')
                cnt++; 
        }
        printf("%d",cnt);
        return 0;
    }

    例题:最长的名字

     

    #include<stdio.h>
    #include<string.h>
    char s[105], ans[105];
    int max;
    int main(){
        int N,len;
        scanf("%d",&N);
        while(N--){
            scanf("%s",s);
            len = strlen(s);
            if(len > max){
                max = len;
                strcpy(ans,s);
            }
        }
        printf("%s",ans);    
        return 0;
    } 

    例题:字符串

    #include<stdio.h>
    #include<string.h>
    char s[1005];
    int main(){
        int len;
        scanf("%s",s);
        len = strlen(s);
        for(int i =0; i < len;i++){
            if(s[i] == 'z'){
                s[i] = 'a';
            }else if(s[i] == 'Z'){
                s[i] = 'A';
            }else if((s[i] >= 'a' && s[i]<= 'z')|| (s[i] >= 'A' && s[i] <= 'Z' )){
                s[i]++;
            } 
        }
        printf("%s",s);
        return 0;
    }

    例题:大数的奇偶数判断

     

    #include<stdio.h>
    #include<string.h>
    char s[10005];
    int main(){
        int len;
        scanf("%s",s);
        len = strlen(s);
        if((s[len -1 ] - '0') % 2 == 0)
            printf("YES");
        else
            printf("NO");
        return 0;
    }

    例题:反向输出

    #include<stdio.h>
    #include<string.h>
    char s[100005];
    int main(){
        int len;
        scanf("%s",s);
        len = strlen(s);
        for(int i = len- 1;i >= 0;i--)
            printf("%c",s[i]);    
        return 0;
    }

     蓝桥杯真题: 十字图

    可以看下这篇博客

    https://blog.csdn.net/weiwanshu/article/details/45152147

    视频中,最后一道题是 节假日 ,在同系列的上一篇博客中也提到了,就不多缀写 

    https://www.cnblogs.com/expedition/p/12275655.html

  • 相关阅读:
    jQuery扩展函数设置所有对象只读
    Jquery一些实用函数
    原码,反码,补码
    数据库查询练习
    已知二叉树的先序遍历和中序遍历画出该二叉树
    linux 下 Google配置SwitchyOmega
    字母和数字转换
    c++产生验证码字符串
    C++产生随机数
    快速排序
  • 原文地址:https://www.cnblogs.com/expedition/p/12298864.html
Copyright © 2020-2023  润新知