c语言程序设计课后习题答案高等教育出版社
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include<>
main()
{
float x=,y=,z=;
printf("x=%f\n",x);
printf("y=%f\n",y);
printf("z=%f\n",z);
}
(1) #include<>
main()
{
int a=12,b=3;
float x=,y=;
printf("%f\n",(float)(a*b)/2);
printf("%d\n",(int)x%(int)y);
}
(2)
#include<> main()
{
int x=32,y=81,p,q;
p=x++;
q=--y;
printf("%d %d\n",p,q); printf("%d %d\n",x,y);
}
#include<>
main()
{
int x,b0,b1,b2,s;
printf("Inputx:");
scanf("%d",&x);
b2=x/100;
printf("骰子出现 2 printf("骰子出现 3 printf("骰子出现 4 printf("骰子出现 5 printf("骰子出现 6
}
(1) void Swap(int *x,int *y)
{
int *pTemp;.\n");
else if(strcmp(userInput,password)<0)
printf("Invalid password!user input else printf("Invalid password!user input>password...\n"); return 0; } #include<> #define N 24 unsigned int CountLetter(char str[]); int main() { char a[N]; printf("Input a letter:\n"); gets(a); printf("The length of the letter is:%d\n",CountLetter(a)); return 0; } unsigned int CountLetter(char str[]) { char *p=str; int c=0,flag=0; while(*p!='\0') { if(*p!=' ') flag=1; else if(flag==1) { c++; flag=0; } p++; } return c+1; } #include<> typedef struct data { int year; int month; int day; }DATA; typedef struct work { char a[14]; char b[10]; char c[6]; }WORK; typedef struct student { char studentName[10]; char studentSex; DATA birthday; WORK profession; }STUDENT; int main() { STUDENT stu={"王刚",'M',{1991,5,19},{"信息工程系","学习人员","学生"}}; printf("stu:%2s%3c%6d/%02d/%02d%4s,%4s,%4s\n",,, , 0; } #include<> #include<> #define N 10 typedef struct people { char peopleName[10]; }PEOPLE; int main() { int sum1=0,sum2=0,sum3=0,sum4=0; int i; char name[N][N]; PEOPLE stu[5]={"zhang","li","wang"}; printf("Enter their name:\n"); for(i=0;i<10;i++) { gets(name[i]); if(strcmp(name[i],stu[0].peopleName)==0) sum1++; else if(strcmp(name[i],stu[1].peopleName)==0) sum2++; else if(strcmp(name[i],stu[2].peopleName)==0) sum3++; else sum4++; } printf("stu:%4s%2d\n",stu[i].peopleName,sum[j]); printf("stu:%4s%2d\n",stu[1].peopleName,sum2); printf("stu:%4s%2d\n",stu[2].peopleName,sum3); printf("%2d\n",sum4); return 0; }