}
5.9
#include <stdio.h>
#include<math.h>
void main(void)
{ char str[6];
int i,j=0,m=0,n=0;
gets(str);
while(str[j]!='\0') j++;
for(i=j-1;i>=0;i--)
{
m=(str[i]-'0')*(pow(8,j-i-1));
n+=m;
}
printf("shijinzhi %d",n);
}
5.10#include <stdio.h>
void main(void)
{
char input1[100];
int i,num=0,blank=0;
printf("Please input a row character:\n");
gets(input1);
/*test the first row*/
for(i=0; i<100; i++)
{
if(input1[i]=='\0')
goto Loop;
else if(('A'<=input1[i])&&(input1[i]<='Z')==1)
num++;
else if(('a'<=input1[i])&&(input1[i]<='z')==1)
num++;
else if (input1[i]==32)
blank++;
}
Loop: printf("Character:%d\nBlank:%d\n",num,blank);
}
第六章
一、选择题
1.D :p中记录的是a的地址,*p访问地址a的值
2.D :指针数组
3.D:指针可以进行是否相等判断,空指针可以进行指针变量初始化,指针可以偏移;
4.C:
5.C、D:a[5]不存在,若*&a[4]则正确;C,D正确;
6.D:
7.B:
8.B:
二、填空题
1.*(p+3) 2 22
2. cdefg
bcdefg
abcdefg
7
3. 6385
三、程序分析题
1.p = s[0] ; 错误,应改为:p = s; 或 p = &s[0];
2.int x , *p;错误,应改为:double x, *p;
3.*p = x ;错误,应改为:p = &x ;
4. 声明顺序错误;应该改为:
void main(void)
{
int a;
int *p = &a;
a = 10;
printf(“%d\n”,*p);
}
2.3 #include <stdio.h>
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说公务员考试华中科技大学标准C语言程序设计及应用习题答案(4)在线全文阅读。
相关推荐: