본문 바로가기
dev/C

[C] other - 1

by seohan1010 2024. 5. 29.

https://pythontutor.com/render.html#mode=display

 

Python Tutor code visualizer: Visualize code in Python, JavaScript, C, C++, and Java

Please wait ... your code is running (up to 10 seconds) Write code in Python 3.11 [newest version, latest features not tested yet] Python 3.6 [reliable stable version, select 3.11 for newest] Java C (C17 + GNU extensions) C++ (C++20 + GNU extensions) JavaS

pythontutor.com

 

 

 

 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main()
{


    char str[30];

    int num;

    scanf("%s %d",str,&num);


    int length = strlen(str);
    if(num < strlen(str)){

        for(int i = 0; i < length - 1  ;i++){

            for(int j =0 ;  j < num;j++){
                printf("%c",str[i+j]);
            }
        printf("\n");

        }
    }else{
        printf("%s\n","wrong");
    }


    return 0;
}

 

 

정수와 문자열을 입력받아서 정수의 수만큼 문자열을 나누어서 출력한다.

'dev > C' 카테고리의 다른 글

[C] 익명구조체  (0) 2024.05.29
[C] 구조체  (0) 2024.05.29
[C] 16진수를 문자열로 출력하기  (0) 2024.05.29
[C] function - atoi  (0) 2024.05.29
[C] function - strrchr()  (0) 2024.05.29