zoukankan      html  css  js  c++  java
  • A1035

    把字符串里指定的字母改成指定的值。

    用二维数组或者结构体。一开始使用的string字符串,但切割成数组的时候可能出现问题导致一个点过不去。

    所以还是用结构体吧。

    题目本身不难。

    注:%s是通过空白符来截断字符串的,包括空格。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <algorithm>
     4 #include <string.h>
     5 #include <cmath>
     6 using namespace std;
     7 const int maxn=1000+5;
     8 struct Node{
     9     char team[15];
    10     char pass[15];
    11 }ans[maxn];
    12 int main()
    13 {
    14     int n;
    15     int cnt=0;
    16     char team[20],pass[20];
    17     scanf("%d",&n);
    18     int flag;
    19     for(int i=0;i<n;i++){
    20         scanf("%s %s",team,pass);
    21         int len=strlen(pass);
    22         flag=0;
    23         for(int j=0;j<len;j++){
    24             if(pass[j]=='1'){
    25                 flag=1;
    26                 pass[j]='@';
    27             }
    28             else if(pass[j]=='0'){
    29                 flag=1;
    30                 pass[j]='%';
    31             }
    32             else if(pass[j]=='l'){
    33                 flag=1;
    34                 pass[j]='L';
    35             }
    36             else if(pass[j]=='O'){
    37                 flag=1;
    38                 pass[j]='o';
    39             }
    40         }
    41         if(flag==1){
    42             strcpy(ans[cnt].team,team);
    43             strcpy(ans[cnt].pass,pass);
    44             cnt++;
    45         }
    46     }
    47     if(cnt==0){
    48         if(n==1)
    49             printf("There is 1 account and no account is modified
    ");
    50         else
    51             printf("There are %d accounts and no account is modified
    ",n);
    52     }
    53     else{
    54         printf("%d
    ",cnt);
    55         for(int i=0;i<cnt;i++){
    56             printf("%s %s
    ",ans[i].team,ans[i].pass);
    57         }
    58     }
    59     return 0;
    60 }
  • 相关阅读:
    【转载】实时嵌入式软件开发的25个常见错误
    软件测试高级测评师培训-白盒测试所用工具
    SQL update select语句
    JS对URL字符串进行编码/解码分析
    Java利用jacob实现文档格式转换
    Web打印--Lodop API
    常用正则表达式
    截取视频第一帧作为预览图片
    plupload api
    URL特殊字符的转义
  • 原文地址:https://www.cnblogs.com/Lynn-2019/p/12116691.html
Copyright © 2011-2022 走看看