Untitled

 avatar
unknown
plain_text
4 years ago
1.0 kB
4
Indexable
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void convert(int a);

int main(void)
{
    /// Method 1 getchar()
    char str[100];
    int i = 0;
    printf("Please input a series of numbers separated by space: ");
    char ch = getchar();

    while(ch != '\n'){
        str[i] = ch;
        i++;
        ch = getchar();
    }

    str[i] = ' ';
    str[i+1] = '\0';

    int temp[10];
    i = 0;
    for(int j = 0; j < strlen(str); j++){
        if(str[j] != ' '){
            temp[i] = str[j];
            i++;
        }
        else{
            int num = atoi(temp);
            convert(num);
            for(int i = 0; i < 10; i++){
                temp[i] = ' ';
            }
            i = 0;
        }
    }

    /// Method 2 scanf
//    char str[100];
//    printf("Please input a series of numbers separated by space: ");
//    scanf("%s", str);



    return 0;
}

void convert(int a){
    int i = a + 96;
    printf("%c", i);
}
Editor is loading...