카타 7급 Complete The Pattern #1

C[ | ]

char* pattern(const int n){
  char* res = calloc(10000, sizeof(char));
  char s[3];
  for(int i=1; i<=n; i++) {
    //sprintf(s, "%d", i);
    sprintf(s, "%c", i+48);
    for(int j=1; j<=i; j++) strcat(res, s);
    if(i!=n) strcat(res,"\n");
  }
  return res;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}