-가 연속적으로 나올때 질문입니다.

Jinner Reply 9 years 3 days ago
#include <stdio.h> #define MAXLINE 8000 void convert(char line[], char cline[]); int main() { char line[MAXLINE]; char cline[MAXLINE]; char c; int i=0; while((c = getchar()) != EOF && i<MAXLINE){ line[i] = c; i++; } line[i] = '\0'; convert(line, cline); printf("%s", cline); c = getchar(); return 0; } void convert(char from[], char to[]) { int i, j, k; j = 0; int gap; for (i = 0; i < MAXLINE && from[i] != '\0'; i++) { if (from[i] == '-') { gap = from[i + 1] - from[i - 1]; if (48 <= from[i - 1] <= 57 && 48 <= from[i + 1] <= 57) { if(from[i+1] > from[i-1]){ for(k=1; k<=gap; k++){ to[j] = from[i-1]+k; j++; } i++; } else if(from[i+1] = from[i-1]){ i++; } else if(from[i+1] < from[i-1]){ to[j] = '-'; i++; j++; to[j] = from[i]; j++; } } else if (65 <= from[i - 1] <= 90 && 65 <= from[i + 1] <= 90) { if(from[i+1] > from[i-1]){ for(k=1; k<=gap; k++){ to[j] = from[i-1]+k; j++; } i++; } else if(from[i+1] = from[i-1]){ i++; } else if(from[i+1] < from[i-1]){ to[j] = '-'; i++; j++; to[j] = from[i]; j++; } } else if (97 <= from[i - 1] <= 122 && 97 <= from[i + 1] <= 122) { if(from[i+1] > from[i-1]){ for(k=1; k<=gap; k++){ to[j] = from[i-1]+k; j++; } i++; } else if(from[i+1] = from[i-1]){ i++; } else if(from[i+1] < from[i-1]){ to[j] = '-'; i++; j++; to[j] = from[i]; j++; } } else { to[j] = '-'; i++; j++; to[j] = from[i]; j++; } } else{ to[j] = from[i]; j++; } } to[j] = '\0'; }