1.12
This commit is contained in:
		
							parent
							
								
									47e0367161
								
							
						
					
					
						commit
						98d51273d9
					
				
							
								
								
									
										35
									
								
								The C Programming Language/1.12.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								The C Programming Language/1.12.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define IN 1
 | 
				
			||||||
 | 
					#define OUT 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					main()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int c, state, word_ending;
 | 
				
			||||||
 | 
						state = 0;
 | 
				
			||||||
 | 
						while ((c = getchar()) != EOF)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							word_ending = (c == ' ' || c == '\n' || c == '\t');
 | 
				
			||||||
 | 
							if (state == IN)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (word_ending)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									state = OUT;
 | 
				
			||||||
 | 
									putchar('\n');
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									putchar(c);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (!word_ending)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									state = IN;
 | 
				
			||||||
 | 
									putchar(c);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user