更多"补充函数,要求实现如下功能:寻找并输出11~999之间的数m,使得m、"的相关试题:
[简答题]补充函数,要求实现如下功能:寻找并输出11~999之间的数m,使得m、m2、m3均为回文数(回文数是指各位数字左右对称的整数),例如:12321、505、1458541等。满足上述条件的数如m=11时,m2=121,m3=1331都是回文数。请编写jsValue(long m)实现此功能。如果是回文数,则函数返回1,不是则返回0。最后,把结果输出到文件OUT.DAT中。
注意:部分源程序已经给出。请勿改动主函数main( )中的内容。
试题程序:
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
int jsValue<long n>
main( )
long m;
FILE*out;
out=fopen("OUT.DAT","w");
for(m=11;m<1000;m++)
if(jsValue(m)&&jsValue(m*m)&&jsValue(m*m*m))
printf("m=%4ld,m*m=%6ld,m*m*m=%
8ld/n",m,m*m,m*m*m);
fprintf(out,"m=%4ld,m*m=%6ld,m*m*m
=%8ld/n",m,m*m,m*m*m);
fclose(out);
[简答题]补充函数,要求实现如下功能:寻找并输出11~999之间的数m,它满足m,m2,m3均为回文数(回文数是指各位数字左右对称的整数),例如:12321,505,1458541等。满足上述条件的数如m=11时,m2=121,m3=1331都是回文数。请编写js-Value(long m)实现此功能。如果是回文数,则函数返回1,不是则返回0。最后,把结果输出到文件OUT.DAT中。
注意:部分源程序已经给出。
请勿改动主函数Main( )中的内容。
试题程序:
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
int js Value(long n)
main( )
long m;
FILE*OUt:
Out=fopen("OUT.DAT","w");
for(m=11;m<1000;m++)
if(jsValue(m)&&jsValue(m*m)&&jsValue(m*m*m))
printf("m=%41d,m*m=%61d,m*m*m=%81d",m,m*m,m*m*m);
fprintf(out,"m=%41d,m*m=%61d,m*m*m=%81d",m,m*m,m*m*m);
fclose(out);
[填空题]请补充main函数,该函数的功能是:输出一个3×3的矩阵,要求必须使用行指针表示输出变量。
注意;部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<s tdio. h>
main( )
static int array[3] [3]=9,8,7, 6,5,
4, (3,2,1;
iht (*p) [3],j,i;
p=【1】
clrscr ( );
for (i=0; i<3; i++)
printf (" /n/n" );
for (j=0; j<3; j++)
printf("%4d", 【2】 );
[填空题]请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素赋值0,周边元素赋值1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio .h>
#define N 10
main( )
{
int bb[N] IN];
iht i,j,n;
clrscr 0;
printf (" /nInput n: /n");
scanf ("%d", &n);
for (i=0; i<n; i++ )
for (j=0; j<n; j++)
{
if(【1】)
bb[i] [j]=l;
else
【2】;
}
printf(" /n*** the result *** /n");
for (i=0; i<n; i++)
{
printf (" /n/n");
for (j=0; j<n; j++)
printf ("%4d",bb [i] [j ] );
}
}
[简答题]请补充函数fun( ),该函数的功能是:寻找两个整数之间的的所有素数(包括这两个整数),把结果保存在数组bb中,函数返回素数的个数。
例如,输入6和21,则输出为:7 11 13 17 19 21。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<conio. h>
#include<stdio. h>
#define N 1000
int fun (int n, int m, int bb [N])
int i, j, k=0, flag;
for (j=n; j<=m; j++)
【1】 ;
for (i=2; i<j; i++)
if( 【2】 )
flag=0;
break;
if( 【3】 )
bb [k++] =j
return k;
main ( )
int n=0,m=0, i, k;
int bb[N];
clrscr ( );
printf ("Input n/n");
scanf ("%d", &n);
printf ("Input m/n");
scanf ("%d", &m);
for (i=0; i<m-n; i++)
bb[i]=0;
k=fun (n, m, bb);
for (i=0; i<k; i++)
printf ("%4d",bb [i]);
[填空题]请补充函数fun( ),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不予删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,a指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。
例如:当a输入“abababa”,c=‘a’时,b的输出为“ababb”;
如果a的输入为“ababa”,则b的输出为“ababa”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
void fun(char a[],char b[],char C)
int i=0,j=0;
int n=0;
int m=0;
while(a[i]!=‘/0’)
if(a[i]==c)
n++;
i++;
【1】 ;
if(n%2)
while(a[j]!=’/0’)
b[j]=a[j];
j++;
b[j]=’/0’;
else
while(a[i]!=’/0’)
b[j++]=a[i];
if(a[i]==c)
m++;
if((m>n/2)&&(a[i]==c))
【2】 ;
i++;
【3】 ;
main( )
char a[LEN],b[LEN];
char c;
[填空题]请补充函数fun( ),该函数的功能是建立一个带头结点的单向链表并输出到文件“out98.dat”和屏幕上,各结点的值为对应的下标,链表的结点数及输出的文件名作为参数传入。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仪在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#include<conio. h>
#include<stdlib. h>
typedef struct ss
int data;
struct ss *next;
NODE;
void fun(int n,char*filename)
NODE *h,*p, *s;
FILE *pf;
int i;
h=p= (NODE *) malloc (sizeof (NODE));
h->data=0;
for (i=1; i
s=(NODE *)malloc (sizeof (NODE));
s->data= 【1】 ;
【2】 ;
p= 【3】
p->next=NULL;
if ( (pf=fopen (filename, "w") ) ==NULL)
printf "Can not open out9B.clat! ");
exit (0);
p=h;
fprintf (pf, "/n***THE LIST***/n");
print f ("/n***THE LIST***/n")
while (p)
fprintf (pf, "%3d", p->data)
printf ("%3d",p->data);
if (p->next ! =NULL)
[填空题]请补充函数fun( ),该函数的功能是:把从键盘输入的3个整数按从小到大输出。
例如:输入“33 78 25”,结果输出“25 33 78”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的横线上填入所编写的若干表达式或语句。
试题程序:
# include<stdio. h>
# include<conio. h>
main( )
{
int x,y, z,t;
clrscr ( );
printf ("Input x, y, z/n");
scanf ("%d%d%d", &x, &y, &z);
if( 【1】 )
{
t=x;
x=y;
y=t;
}/*变换x, y的值*/
if( 【2】 )
t=z;
z=x;
x=t;
}/*交换x, z 的值*/
if( 【3】 )
{
t=y;
y=z;
z=t;
}/*变换 z, y 的值*/
printf("******the result*******/n");
printf("from small to big: %d %d %d/n",
x, y, z);
}
[填空题]请补充函数fun( ),函数fun( )的功能是求7的阶乘。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
long fun(int n)
if( 【1】 )
return(n*fun( 【2】 );
else if( 【3】 )
return 1;
main( )
int k=7;
printf("%d!=%ld/n", k, fun(k));
[填空题]请补充main函数,该函数的功能是:把1~100间的所有素数保存在数组aa中,然后输出这些素数并计算它们的和。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
main( )
int n, i, j, k, flag, sum;
int aa [50];
sum=O;
k=O;
clrscr ( );
for (i=2; i<100; i++)
【1】;
for (j=2; j<i&&flag; j++)
if (i%j==O)
【2】;
if (flag)
sum+=i;
【3】;
printf("/n*** prime number ***/n");
for (i=0; i<k; i++)
if (i%10==0)
printf ("/n");
printf ("%4d", aa [i]);
printf ("/nsum=%d", sum);
[填空题]请补充main函数,该函数的功能是:从键盘输入3个整数,然后找出最大的数并输出。
例如,输入:12,45,43,最大值为45。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
main( )
int a, b, c, max;
clrscr( );
printf("/nlnput three numbers:/n");
scanf("%d,%d,%d",&a,&b,&c);
printf("The three numbers are:%d,
%d,%d/n",a,b,c);
if(a>b)
【1】 ;
else
【2】 ;
if(max<c)
【3】 ;
printf("max=%d/n",max);