Language:c++ 4.8.2
#include <stdio.h>#include<string.h>intMainvoid){ intN; intSum//record the number of spaces in each set of data intCount//number of record lines intlength; intMin_space; Charstr[ -]; while(1) {Min_space= -; Sum=0; scanf ("%d\n", &n);//notice here scanf inside of ' \ n ', it is not the common bug, but for the following fgets do pave the way, otherwise Fgets's first read will fill a newline in str and then end with '. if(n = =0) Break; intm =N; while(m--)//initially did not save the value of N, but directly n--, resulting in the subsequent printf calculation of the cup, the output of a look, immediately realized that this piece has a problem, then changed. {Count=0; Fgets (str,sizeof(str), stdin); Length= strlen (str)-1;//Fgets reads the character length and the actual character length in case there is enough space to be different. for(inti =0; i < length; i++) { if(Str[i] = =' ') {sum++; Count++; } } if(Min_space >count) Min_space=count; } printf ("%d\n", sum-n*min_space); } return 0;}
uva_414:machined surfaces