- 讲师:刘萍萍 / 谢楠
- 课时:160h
- 价格 4580 元
特色双名师解密新课程高频考点,送国家电网教材讲义,助力一次通关
配套通关班送国网在线题库一套
请编写一个函数unsigned fun (unsigned w),w 是一个大于 10的无符号整数,若w是n(n≥2)位的整数,则函数求出w的后 n-1位的数作为函数值返回。
例如:w值为5923,则函数返回923;若w值为923,则函数返回23。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。
试题程序:
include<conio. h>
include<stdio. h>
unsigned fun(unsigned w)
{
}
main()
{
unsigned x;
clrscr ();
printf("Enter a unsigned integer
number: ");
scanf ("%u",&x);
printf("The original data is:%un",x);
if (x<10)
printf ("Data error! ");
else
printf ("The result :%un", fun(x) );
}
请补充函数fun(),该函数的功能是:求100(不包括100)以内能被2或5整除,但不能同时被2和5整除的自然数。结果保存在数组bb中,函数fun()返回数组比元素的个数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 100
int fun (int bb [] )
{
int i, j;
for(【 】;i<100; i++)
if ((i%1!=0&&i%5==0)|| (i%2==0&&i%5 !=0)
【 】;
【 】;
}
main()
{
int i, n;
int bb [N];
clrscr ();
n=fun (bb);
for(i=0; i<n; i++)
{
if (i%10==0)
printf ("n");
printf ("% 4d", bb [i]);
}
}
请编写一个函数,用来删除字符串中的所有空格。
例如:输入asd af aa z67,则输出为asdafaz67。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<stdio.h>
include<ctype.h>
include<conio.h>
int fun(char*str)
{
}
main()
{
char str[81];
int n;
clrscr();
printf("Input a string:");
gets(str);
puts(str);
fun(str);
printf("*** Str: %sn",str);
}
以下程序运行后的输出结果是【 】。
main()
{ int p[7]={11,13,14,15,16,17,18};
int i=0,j=0;
while(i<7&&p[i]%2==1)j+=p[i++];
printf("%dn",j);
}
学生的记录由学号和成绩组成,N名学生的数据己在主函数中放入结构体数组s中,请编写函数fun(),它的功能是:把分数最低的学生数据放在h所指的数组中。注意:分数低的学生可能不只一个,函数返回分数最低学生的人数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
define N 16
typedef struct
{char num[10];
int s;
}STREC;
int fun (STREC *a,STREC *b)
{
}
main ()
{
STREC s[N]={{“GA005”,82},{“GA003”,75},
{“GA002”,85},{“GA004”,78},{“GA001”,95},
{“GA007”,62},{“GA008”,60},{“GA006”,85},
{“GA015”,83},{“GA013”,94},{“GA012”,78},
{“GA014”,97},{“GA011”,60},{“GA017”,65},
{“GA018”,60},{“GA016”,74}};
STREC h[N];
int i,n;
FILE *out;
n=fun(S,h);
printf(“The %d lowest score:n”,n);
for (i=0; i<n; i++)
printf(“%s %4dn”,h[i].mum,h[i].s);
/*输出最低分学生的学号和成绩*/
printf(“n”);
out=fopen("outl9.dat",“w”);
fprintf(out,“%dn”,n);
for(i=0; i<n; i++);
fprintf(out, “%4dn”,h[i].s);
fclose(out);
}
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
点击加载更多评论>>