2、char *gets(char *str)
str -- This is the pointer to an array of chars where the C string is stored.
This function returns str on success, and NULL on error or when end of file occurs while no characters have been read. Null is defined 0
测试用例无限输入,每个测试用例占用一行
char str[N] ; while(gets(str)) { int n = strlen(str) ; if(0==n) //空行跳过 { printf("\n") ; continue ; } }
#include <string.h>
Sets the first num bytes of the block of memory pointed by ptr to the specified value
4、测试用例以0结束
double d ; while(1==scanf("%lf",&d)&&d) { }或者
while (true) { double d ; scanf("%lf",&d) ; if(d==0.0) break ; }
long long a[n] ; double d ; printf(“%6.2lf%17I64d\n”,d,a[n]) //d小数部分两位,向右对齐,宽度为6,数组也向右对齐,宽度为17
printf("%-6.2lf\n",5.2) ;向右对齐,左边以前导0填充,只需要加0
printf("%06.2lf\n",5.2) ;