题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <stdio.h> #define STR_LEN 9 int m_strlen(const char *str) { int len = 0; while(str[len] != '\0') { len++; } return len; } int main() { char str[STR_LEN]; char * ptr = str; int len; while(scanf("%8[^\n]", ptr) > 0) { len = m_strlen(str); for(int i = STR_LEN - 1; i >= len; i--) { str[i] = '0'; } str[STR_LEN - 1] = '\0'; printf("%s\n", str); ptr = str; } return 0; }