[例3-1]
#include<stdio.h>
int main(void)
{
int digit,i,letter,other;
char ch;
digit=letter=other=0;
printf("Enter 10 characters:");
for(i=1;i<=10;i )
{
ch=getchar();
if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
letter ;
else if(ch>='0'&&ch<='9')
digit ;
else
other ;
}
printf("letter=%d,digit=%d,other=%d\n",letter,digit,other);
return 0;
}
[例3-3]
#include<stdio.h>
int main(void)
{
double x,y;
printf("Enter x:");
scanf("%lf",&x);
if(x<0)
{
y=0;
}
else if(x<=15)
{
y=4*x/3;
}
else
{
y=2.5*x-10.5;
《C语言程序设计》第三章例题源代码
最新推荐文章于 2022-10-03 22:15:59 发布