A.20,10
B.20,20
C.10,20
D.10,10
若有定义:int x=0, *p=&x;, 则语句 printf("%d\n",*p);的输出结果是()。
A.随机值
B.0
C.x 的地址
D.p的地址
A.for(i=0;i<6;i++) printf("%2d",*(p++));
B.for(i=0;i<6;i++) printf("%2d",*(p+i));
C.for(i=0;i<6;i++) printf("%2d",*p++);
D.for(i=0;i<6;i++) printf("%2d",(*p)++);
A.scanf("%d",&p);
B.printf("%d/n",p);
C.*p=&n;
D.int n,*p=NULL;
有以下程序 #include main() {int n,*p=NULL; *p=&n; printf(“Input n:”); scanf(“%d”,&p); printf(“output n:”); printf(“%d\\n”,p); }
该程序试图通过指针p为变量n读入数据并输出,但程序有多处错误,以下语句正确的是()。
A.int n,*p=NULL;
B.*p=&n;
C.scanf(“%d”, &p)
D.printf(“%d\n”,p);
请编写函数fun(),它的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从0到p(含p,p<n-1)的数组元素平移到数组的最后。例如:一维数组中的原始内容为:1,2,3,4,5,6,7,8,9,10;p的值为3。移动后,一维数组中的内容应为: 5,6,7,8,9,10,1,2,3,4。部分源程序在文件PROG1.C中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
include<stdiO.h>
define N 80
void fun(int *w,int p,int n)
{
}
main()
{in[ a[N]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
int i,p,n=15;
printf("The odginal data:\n");
for(i=0;i<n;i++)printf("%3d",a[i]);
printf("\nEnter p:");
scanf("%d",&p);
fun(a,p,n);
printf ("\n The data after moving:\n");
for(i=0;i<n;i++)printf("%3d”,a[i]);
}
请补充函数fun(),该函数的功能是:从‘a’到‘z’统计一个字符串中所有字母字符各自出现的次数,结果保存在数组aIf中。注意:不区分大小写,不能使用字符串库函数。
例如,输入: “A=abc+5*c”,结果为:a=2, b=l,c=2。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数run的横线上填入所编写的若干表达式或语句。
试题程序:
include<conio.h>
include<stdio.h>
define N 100
void fun(char *tt,int alf[])
{
int i
char *p=tt;
for(i=0;i<26;i++)
【 】;
while(*p)
{
if(*p>='A'&&*p<='z')
【 】;
if(*p>='a'&&*p<='Z')
alf[*p-'a']++;
【 】;
}
}
main()
{
char str[N];
char a='a';
int alf[26],k;
clrscr();
printf("\nPlease enter a char string:");
scanf("%S",str);
printf("\n**The original string**\n");
puts(str);
fun(str,alf);
printf("\n**The number of letter**\n");
for(k:0;k<26;k++)
{
if(k%5==0)
printf(“\n”);
printf(“%c=%d”,a+k,alf[k]);
}
printf(“\n”);
}
请编写函数fun(),该函数的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从0到p(p≤n-1)的数组元素平移到数组的最后。
例如,一维数组中的原始内容为1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,p的值为3。移动后,一维数组中的内容应为5,6,7,8,9,10,11,12,13,14,15, 1, 2, 3, 4。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
define N 80
void fun(int *w, int p, int n)
{
}
main ()
{
int a[N]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
int i, p, n=15;
printf("The original data:\n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("\n\nEnter p: ");
scanf("%d",&p);
fun(a,p,n);
printf("\nThe data after moving:\n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("\n\n");
}