ACM杂记(技巧/注意事项/常用函数)

来源:互联网 发布:淘宝怎么开通游戏专营 编辑:程序博客网 时间:2024/05/16 01:50

判断到了字符串的末尾


main()
{
int i=0 ;
char s[10];
scanf("%s",s);

 while(s[i]!=''){                     /*这里可以用'',也可以用'/0'来判断到了字符串的末尾*/
   printf("s is not empty/n");
   i++;
 }

printf("now is empty");

}

 


 

/*按行输入到字符串数组
输入:要存放字符串的数组地址
*/
#include <stdio.h>
void LineInput(char s[])
{
char s[50];
int i=0;
while( (s[i++]=getchar()) !='/n'   );
}


如要求一个数的最后一位不能用:
int x;
printf("%d",(x/10.0+floor(x/10.0))*10.0);

而应是:printf("%d",(int)(x/10.0+floor(x/10.0))*10.0);

%d不能输出FLOAT

原创粉丝点击