Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #define LINESIZE 20
- int main()
- {
- int c, cnt, i, lspc;
- char charray[LINESIZE];
- for(cnt = 0;cnt < LINESIZE; cnt++)
- charray[cnt] = 0;
- cnt = 0;
- lspc = -1;
- while((c = getchar()) != EOF) {
- if(cnt < LINESIZE) {
- if(c == '\n') {
- for(i = 0;i < cnt;i++)
- putchar(charray[i]);
- for(i = 0;i < cnt;i++)
- charray[i] = 0;
- } else {
- if(c == ' ')
- lspc = cnt;
- charray[cnt++] = c;
- }
- } else {
- if(c == ' ' || c == '\n') {
- for(i = 0;i < cnt;i++)
- putchar(charray[i]);
- for(i = 0;i < cnt;i++)
- charray[i] = 0;
- } else {
- if(lspc != -1) {
- for(i = 0;i < lspc;i++)
- putchar(charray[i]);
- for(i = 0;i < cnt;i++)
- charray[i] = 0;
- } else {
- for(i = 0;i <= cnt;i++)
- putchar(charray[i]);
- for(i = 0;i <= cnt;i++)
- charray[i] = 0;
- putchar('-');
- }
- }
- putchar('\n');
- lspc = -1;
- cnt = 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment