Notice
Recent Posts
Recent Comments
Link
반응형
변명은 만개 결과는 한개
[백준 11721] 열 개씩 끊어 출력하기 본문
728x90
반응형
https://www.acmicpc.net/problem/11721
11721번: 열 개씩 끊어 출력하기
첫째 줄에 단어가 주어진다. 단어는 알파벳 소문자와 대문자로만 이루어져 있으며, 길이는 100을 넘지 않는다. 길이가 0인 단어는 주어지지 않는다.
www.acmicpc.net
< 내 코드 >
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
char num[100] = { 0, };
scanf("%s", num);
int a = strlen(num) / 10;
int b = strlen(num) % 10;
int total = 0;
for (int i = 0; i < a; i++) {
for (int j = 0; j < 10; j++) {
printf("%c", num[total]);
total++;
}
printf("\n");
}
for (int i = 0; i < b; i++) {
printf("%c", num[total]);
total++;
}
return 0;
}
< 코멘트 >
1. strlen 쓰려면 string.h include 시키자 -_-
728x90
반응형
'공부 > Problem Solving' 카테고리의 다른 글
[BFS] 단지 번호 붙이기 (0) | 2019.10.22 |
---|---|
배열을 입력받기 (0) | 2019.10.12 |
[백준 11720] 숫자의 합 (0) | 2019.05.16 |
[백준 8393] 합 (0) | 2019.05.15 |
[백준 1924] 2007년 (0) | 2019.05.14 |