zoukankan      html  css  js  c++  java
  • [ CodeVS冲杯之路 ] P1165

      不充钱,你怎么AC?

      题目:http://codevs.cn/problem/1165/

      题目很简单,代码最好写朴实一点,不要想着哪些情况可以合并在一起啊等等

      老老实实一个个判断,不然很容易出错

      细节很多,幸好样例给的良心,可以检测出很多细节

      自己字符串模拟即可,一定要细心!

     1 #include<cstdio>
     2 #include<cstdlib>
     3 #include<cstring>
     4 #include<cmath>
     5 #include<iostream>
     6 #include<algorithm>
     7 using namespace std;
     8 
     9 char s[101];
    10 int main()
    11 {
    12     int p1,p2,p3,i,j,k;
    13     scanf("%d%d%d
    %s",&p1,&p2,&p3,s);
    14     int len=strlen(s);
    15     for (i=0;i<len;i++)
    16     {
    17         if (s[i]=='-')
    18         {
    19             if (s[i-1]>=s[i+1]) putchar('-');
    20             else
    21             if (s[i-1]>='0'&&s[i-1]<='9'&&s[i+1]>='0'&&s[i+1]<='9')
    22             {
    23                 if (p3==1)
    24                 {
    25                     for (j=s[i-1]+1;j<s[i+1];j++)
    26                         for (k=1;k<=p2;k++) putchar(p1==3?'*':j);
    27                 }
    28                 else
    29                 {
    30                     for (j=s[i+1]-1;j>s[i-1];j--)
    31                         for (k=1;k<=p2;k++) putchar(p1==3?'*':j);
    32                 }
    33             }
    34             else if (s[i-1]>='a'&&s[i+1]<='z'&&s[i-1]<='z'&&s[i+1]>='a')
    35             {
    36                 if (p1==1)
    37                 {
    38                     if (p3==1)
    39                     {    
    40                         for (j=s[i-1]+1;j<s[i+1];j++)
    41                             for (k=1;k<=p2;k++) putchar(j);
    42                     }
    43                     else
    44                     {
    45                         for (j=s[i+1]-1;j>s[i-1];j--)
    46                             for (k=1;k<=p2;k++) putchar(j);
    47                     }
    48                 }
    49                 else if (p1==2)
    50                 {
    51                     if (p3==1)
    52                     {    
    53                         for (j=s[i-1]+1;j<s[i+1];j++)
    54                             for (k=1;k<=p2;k++) putchar(j-32);
    55                     }
    56                     else
    57                     {
    58                         for (j=s[i+1]-1;j>s[i-1];j--)
    59                             for (k=1;k<=p2;k++) putchar(j-32);
    60                     }
    61                 }
    62                 else
    63                 {
    64                     if (p3==1)
    65                     {    
    66                         for (j=s[i-1]+1;j<s[i+1];j++)
    67                             for (k=1;k<=p2;k++) putchar('*');
    68                     }
    69                     else
    70                     {
    71                         for (j=s[i+1]-1;j>s[i-1];j--)
    72                             for (k=1;k<=p2;k++) putchar('*');
    73                     }
    74                 }
    75             }
    76             else putchar('-');
    77         }
    78         else putchar(s[i]);
    79     }
    80     return 0;
    81 }
  • 相关阅读:
    leetcode-9-basic-binary search
    selection problem-divide and conquer
    leetcode-8-pointer
    leetcode-7-hashTable
    前端学习之——js解析json数组
    Google浏览器如何加载本地文件
    JAVA全栈工程师应具备怎样的知识体系?
    Java全栈工程师知识体系介绍
    数据可视化工具
    使用js的FileReader对象
  • 原文地址:https://www.cnblogs.com/hadilo/p/5956511.html
Copyright © 2011-2022 走看看