Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
2
Indexable
Never
#include <stdlib.h>
#include <stdio.h>

int main() {

    char a = 'a';
    char A = 'A';
    int number = 0;
    char character, basura;
    int i = 0;

    int diff = a - A;

    printf("Number? ");
    scanf("%d", &number);
    scanf("%c", &basura);
    printf("Character? ");
    scanf("%c", &character);
    scanf("%c", &basura);


    for(i = 0; i < number; i++) {

        if((character >= 'a' && character <= 'z')) {
            if(i == number-1) {
                printf("%c\n", character);
            } else {
                printf("%c ", character);
            }

            if(character == 'z') {
                character = 'a';
                character = character - diff;
            } else {
                character = character+1 - diff;
            }

        } else {
            if(i == number-1) {
                printf("%c\n", character);
            } else {
                printf("%c ", character);
            }

            if(character == 'Z') {
                character = 'A';
                character = character + diff;
            } else {
                character = character+1 + diff;
            }
        }

    }

    return 0;
}