一段很简单的C语言代码,看不懂,求高手解答 5
#include<stdio.h>voidmain(){charstr[40];intcmp(char*str1,char*str2);printf("Pleaseent...
#include <stdio.h>
void main()
{
charstr[40];
intcmp( char *str1, char *str2 );
printf("Pleaseenter the website you like the best : ");
scanf("%s",str);
#ifndef CORRECT
#define CORRECT "fishc.com"
#endif
if(cmp( str, CORRECT ) == 0 )
{
printf("\nYeah!You are a smart man!\n\n");
}
else
{
printf("\nYoufool! Man!!\n\n");
}
}
int cmp( char *str1, char *str2 )
{
inti = 0, j = 0;
while(str1[i] )
{
while(str2[j] == str1[i] )
{
i++;
j++;
if(!str2[j] )
{
return0;
}
}
j= 0;
i++;
}
return-1;
}
cmp( , )函数中,while循环是怎么实现各个字符比较?
if(!str2[j] )又是什么意思啊。 展开
void main()
{
charstr[40];
intcmp( char *str1, char *str2 );
printf("Pleaseenter the website you like the best : ");
scanf("%s",str);
#ifndef CORRECT
#define CORRECT "fishc.com"
#endif
if(cmp( str, CORRECT ) == 0 )
{
printf("\nYeah!You are a smart man!\n\n");
}
else
{
printf("\nYoufool! Man!!\n\n");
}
}
int cmp( char *str1, char *str2 )
{
inti = 0, j = 0;
while(str1[i] )
{
while(str2[j] == str1[i] )
{
i++;
j++;
if(!str2[j] )
{
return0;
}
}
j= 0;
i++;
}
return-1;
}
cmp( , )函数中,while循环是怎么实现各个字符比较?
if(!str2[j] )又是什么意思啊。 展开
1个回答
展开全部
scanf("分数= %d\n",&score);是错的,这样会导致你无法输入任何数据。 不信你可以先给score赋一个初值,然后 printf("%d",score);就会发现score永远是初值。 应该写成scanf("%d",&score); 如果你需要显示“分数=”,应该再用一个printf #include<stdio.h>void main(){ int score; printf("请输入分数:\n"); scanf("%d",&score); printf("分数= %d\n",score); while((score<0)||(score>100)) { printf("错误,请重新输入\n"); scanf("分数= %d\n",&score); } switch(score) { case 100:printf("%s","A");break; case 90 :printf("%s","B");break; case 80 :printf("%s","C");break; case 70 :printf("%s","D");break; case 60 :printf("%s","D");break; case 50 :printf("%s","D");break; case 40 :printf("%s","D");break; case 30 :printf("%s","D");break; case 20 :printf("%s","D");break; case 10 :printf("%s","D");break; case 0 :printf("%s","D");break; }}
追问
别逗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询