J.H


私信TA

用户名:dotcpp0649969

访问量:3202

签 名:

等  级
排  名 78
经  验 9372
参赛次数 1
文章发表 135
年  龄 0
在职情况 学生
学  校 桂林理工大学
专  业 计算机科学与技术

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

#include <stdio.h>

#include <string.h>

#include <ctype.h>

 

int main() {

    int p1, p2, p3, i, j;

    char str[101], c;

    scanf("%d %d %d", &p1, &p2, &p3);

    scanf("%s", str);

 

    for (i = 0; i < strlen(str); i++) {

        if (str[i] != '-') {

            printf("%c", str[i]);

        } else {

            if (isalpha(str[i - 1]) && isalpha(str[i + 1]) && str[i - 1] < str[i + 1]) {

                if (p3 == 1) {

                    if (p1 == 1) {

                        for (c = (char)(tolower(str[i - 1]) + 1); c < tolower(str[i + 1]); c++) {

                            for (j = 1; j <= p2; j++) {

                                printf("%c", c);

                            }

                        }

                    } else if (p1 == 2) {

                        for (c = (char)(toupper(str[i - 1]) + 1); c < toupper(str[i + 1]); c++) {

                            for (j = 1; j <= p2; j++) {

                                printf("%c", c);

                            }

                        }

                    } else if (p1 == 3) {

                        int times = (int)(tolower(str[i + 1]) - tolower(str[i - 1])) - 1;

                        for (j = 1; j <= p2 * times; j++) {

                            printf("*");

                        }

                    }

                } else if (p3 == 2) {

                    if (p1 == 1) {

                        for (c = (char)(tolower(str[i + 1]) - 1); c > tolower(str[i - 1]); c--) {

                            for (j = 1; j <= p2; j++) {

                                printf("%c", c);

                            }

                        }

                    } else if (p1 == 2) {

                        for (c = (char)(toupper(str[i + 1]) - 1); c > toupper(str[i - 1]); c--) {

                            for (j = 1; j <= p2; j++) {

                                printf("%c", c);

                            }

                        }

                    } else if (p1 == 3) {

                        int times = (int)(toupper(str[i + 1]) - toupper(str[i - 1])) - 1;

                        for (j = 1; j <= p2 * times; j++) {

                            printf("*");

                        }

                    }

                }

            } else if (isdigit(str[i + 1]) && isdigit(str[i - 1]) && str[i + 1] > str[i - 1]) {

                if (p1 == 3) {

                    int times = str[i + 1] - str[i - 1] - 1;

                    for (j = 1; j <= times * p2; j++) {

                        printf("*");

                    }

                } else {

                    if (p3 == 1) {

                        for (c = str[i - 1] + 1; c < str[i + 1]; c++) {

                            for (j = 1; j <= p2; j++) {

                                printf("%c", c);

                            }

                        }

                    } else if (p3 == 2) {

                        for (c = str[i + 1] - 1; c > str[i - 1]; c--) {

                            for (j = 1; j <= p2; j++) {

                                printf("%c", c);

                            }

                        }

                    }

                }

            } else {

                printf("-");

            }

        }

    }

    printf("\n");

 

    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区