/*程序的功能是:求1到10的阶乘的和*/ #include "stdio.h" int main () { int n,j,s=0,t; for(n=1;n<=10;n++) { ; for(j=1;j<=n;j++) t=t*j; s=s+t; } printf("s=%dn",s); return 0; }
/*程序的功能是:求1到10的阶乘的和*/ #include "stdio.h" int main () { int n,j,s=0,t; for(n=1;n<=10;n++) { ; for(j=1;j<=n;j++) t=t*j; s=s+t; } printf("s=%dn",s); return 0; }
参考答案和解析
r*x
相关考题:
有以下程序#include stdio.h#include string.hvoid fun(char s[][10],int n){ char t;int i,j;for(i=0;in-1;i++)for(j=i+1;jn;j++)/* 比较字符串的首字符大小,并交换字符串的首字符 */if (s[i][0] s[j][0]) {t=s[i][0];s[i][0]=s[j][0];s[j][0]=t;}}main(){ char ss[5][10]={"bcc","bbcc","xy","aaaacc","aabcc"};fun(ss,5); printf("%s,%s\n",ss[0],ss[4]);}程序运行结果是A)xy,aaaaccB)aaaacc,xyC) xcc,aabccD) acc,xabcc
有以下程序#include stdio.hvoid fun(int *s,int nl,int n2){ int i,j,t;i=nl; j=n2;while(ij) {t=s[i];s[i]=s[j];s[j]=t;i++;j--;}}main( ){ int a[10]={1,2,3,4,5,6,7,8,9,0},k;fun(a,0,3); fun(a,4,9); fun(a,0,9);for(k=0;k10;k++)printf("%d",a[k]); printf("\n");}程序运行的结果是 ( )A)0987654321B)4321098765C)5678901234D)0987651234
下面程序的功能是从输入的十个字符串中找出最长的那个串。请在________处填空。#include "stdio.h"#include "string.h"#define N 10main(){char s[N][81], * tint jfor (j=0 jgets (s[j])t= *sfor (j=1 jif(strlen(t)printf("the max length of ten strings is: %d, %s\n", strlen(t), t)}A.t=s[j]B.t=&s[j]C.t= s++D.t=s[j][0]
有以下程序inclUdevoidfun(int*s,intn1,intn2){inti,j,t;i=n1;j=n2;while(i 有以下程序 #inclUde <stdio.h> void fun(int *s,int n1,int n2) { int i,j,t; i=n1; j=n2; while(i<j) {t=s[i];s[i]=s[j];s[j]=t;i++;j--;} } main() { int a[10]={1,2,3,4,5,6,7,8,9,0},k; fun(a,0,3); fun(a,4A.0987654321B.4321098765C.5678901234D.0987651234
有以下程序:includeincludevoid fun(char s[][10],int n){char t;int i,j; 有以下程序: #include<stdio.h> #include<string.h> void fun(char s[][10],int n) { char t;int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) /*比较字符串的首字符大小,并交换字符串的首字符*/ if(s[i][0]>s[j][0]){t=s[i][0];s[i][0]=s[j][0];sEj][0]=t;} } main() {char s[5][10]={"bcc","bbcc","xy","aaaacc","aabcc"); fun(ss,5);printf("%s,%s\n",ss[0],ss[4]); } 程序的运行结果是( )。A.xy,aaaaccB.aaaacc,xyC.xcc,aabccD.acc,xabcc
有下列程序: include include "string.h" void tim(char *s[],int n) 有下列程序: #include <stdio.h> #include "string.h" void tim(char *s[],int n) { char *t;int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])) {t=s[i];s[i]=s[j];s[j]=t;} } main() { char *ss[]= {"bcc","bbcc","xy","aaaacc","aabcc"}; fun(ss,5);printf("%s,%s\n",ss[0],ss[4]); } 程序的运行结果是( )。A.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc
有以下程序#include stdio.h#include string.hvoid fun(char *s[],int n){ char *t; int i,j;for(i=0;in-1;i++)for(j=i+1;jn;j++)if(strlen(s[i])strlen(s[j])) {t=s[i];s[i]:s[j];s[j]=t;}}main(){ char *ss[]={"bcc","bbcc","xy","aaaacc","aabcc"};fun(ss,5); printf("%s,%s\n",ss[0],ss[4]);}程序的运行结果是A.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc
有以下程序: include using namespace std; constxntN=5; int fun(char*s,char a,int 有以下程序:include <iostream>using namespace std;const xnt N=5;int fun(char *s,char a,int n){int j;*s=a;j=n;while(a<s[j])j--;return j;}int main(){char s[N+1];int k;
求主次对角线之和。 main {static int a[ ][3]={9,7,5,1,2,4,6,8}; int I,j,s1=0,s2=0; for(I=0;I3;I++) for(j=0;j3;j++) {if(__________) s1=s1+a[I][j]; if( __________ ) s2=s2+a[I][j]; } printf(“%d\n%d\n”,s1,s2); }
以下程序的输出结果是【 】。include defineN 5 int fun(int *s,int a,int n) {int j; *s= 以下程序的输出结果是【 】。include <stdio.h>define N 5int fun(int *s,int a,int n){ int j;*s=a j=n;while(a!=s[j]) j-;return j;main(){ int s[N+1]; int k:for(k=1 ;k<=N;k++) s[k]=k+1:print f("%d\n",fun(s,4,N));}
请补充函数fun(),该函数的功能是:计算N×N维矩阵元素的方差,结果由函数返回。维数N在主函数中输入。例如:注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>include <conio.h>include <stdlib.h>include <math.h>define N 20double fun(【 】,int n){int i,j;int k;double s=0.0;double f=0.0;double aver=0.0;double sd=0.0;for(i=0;i<n;i++)for(j=0;j<n;j++)s+=a[i][j];aver=【 】;for(i=0;i<n;i++)for(j=0;i<n;j++)f+=(a[i][j]-aver)*(a[i][j]-aver);f/(n*n);sd=【 】;return sd;}main(){int a[N][N];int n;int i,j;double s;clrscr();printf("***+Input the dimension ofarray N*****\n");scanf("%d",n);printf("***** The array *****\n");for(i=0;i<n;i++){for(j=0;j<n;j++){a[i][j]=rand()%50;while(a[i][j]=0)a[i][j]=rand()%60;printf("%4d",a[i][j]);}printf("\n\n");}s=fun(a,n);printf("******* THE RESULT *******\n");printf("%4.3f\n",s);}
下列给定程序中fun()函数的功能是:将n个无序整数从小到大排序。请改正程序中的错误,使它能得出正确的结果。注意;不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>include <stdlib.h>fun(int n, int *a){ int i,j,p,t;for (j=0;j<n-1;j++){ P=j;/***************found*******************/for(i=j+l;i<n-1;i++)if (a[p]>a[i])/***************found*******************/t=i;if (p!=j){t=a[j];a[j]=a[p];a[p]=t;}}}putarr( iht n,int *z){int i;for (i=l;i<=n;i++,z++){ printf("%4d",*z);if (!(i%10)) printf("\n");} printf ("\n");}main (){int aa[20]={9,3,0,4,1,2,5,6,8,10,7},n=11;clrscr();printf("\n\nBefore sorting %d numbers:\n",n); putarr(n,aa);fun(n,aa);printf("\nAfter sorting %d numbers:\n",n);putarr(n,aa);}
有以下程序 include include void fun(char s[][10],int n 有以下程序 #include <stdio.h> #include <string.h> void fun(char s[][10],int n) { char t; int i j; for (i=0; i<n-1; i++) for 0--i+l; j<n; j++) /*比较字符串的首字符大小,并交换字符串的首字符*/ if(s[i][0] > s[j][0]) { t = s[i][0]; s[i][0] = s[j][0]; s[j][0] = t;} } main() { char ss[5][10]= {"bcc", "bbcc", "xy", "aaaacc", "aabcc" }; fun(ss, 5); printf("%s,%s\n", ss[0],ss[4]); } 程序的运行结果是A.xy, aaaaccB.aaaacc,xyC.xcc,aabccD.acc,xabcc
有以下程序:includeincludevoid fun(char*s[],int n){char*t;int i,j;for( 有以下程序: #include<stdio.h> #include<string.h> void fun(char*s[],int n) { char*t;int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])){t=s[i];s[i]=s[j];s[j]=t;} } main() { Char*ss[]={"bcc","bbcc","xy","aaaacc","aabcc"}; fun(ss,5);printf("%s,%s\n",ss[0],ss[4]); } 程序的运行结果是( )。A.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc
有以下程序includeincludevoidfun(char*s[],intn){char*t;int i,j;for(i=0 有以下程序 #include <stdio.h> #include <string.h> void fun(char *s[],int n) { char *t; int i,j; for(i=0;i<n-1;++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])) {t=s[i];s[i];s[j];s[j]=t;} } main() { char *ss[]={"bccA.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc
有以下程序:include int f(int b[] [4]){int i,j,s=0; for(j=0;j2) 有以下程序: #include <stdio.h> int f(int b[] [4]) { int i,j,s=0; for(j=0;j<4;j++) { i=j; if(i>2) i=3-j; s+=b[i][j]; } return s; } main() { int a[4][4]={{1,2,3,4},{0,2,4,6},{3,6,9,12},{3,2,1,0}}; printf("%d\n",f(a)); } 执行后的输出结果是( )。A.12B.11C.18D.16
以下程序的输出结果是()。includemain(){int a[3][3]={0,1,2,0,1,2,0,1,2},i,j,s=1;for 以下程序的输出结果是( )。 #include<stdio.h> main() {int a[3][3]={0,1,2,0,1,2,0,1,2},i,j,s=1; for(i=0;i<3;i++) for(j=i;j<=i;j++) s+=a[i][a[j][j]]; printf("%d\n",s); }A.3B.4C.1D.9
有下列程序: include void fun(int * s,int n1,int n2) { int i,j, 有下列程序: #include <stdio.h> void fun(int * s,int n1,int n2) { int i,j,t; i=n1;j=n2; while(i<j){t=s[i];s[i]=s[j];s[j]=t;i++;j--;} } main() { int a[10]={1,2,3,4,5,6,7,8,9,0},k; fun(a,0,3); fun(a,4,9);fun(a,0,9); for(k=0;k<10;k++)printf("%d",a[k]);printf("\n"); } 程序的运行结果是( )。A.987654321B.4321098765C.5678901234D.987651234
有以下程序:includeint f(int t[],int n);main(){int a[4]={1,2,3,4},s;s=f(a,2);prin 有以下程序: #include<stdio.h> int f(int t[],int n); main() {int a[4]={1,2,3,4},s; s=f(a,2);printf("%d\n",s); } int f(int t[],int n) {if((n>0)(n<5))return t[n+1]+f(t,n-1); else return 0; } 程序运行后的输出结果是( )。A.4B.7C.10D.61
有以下程序:struct S{int n;int a[20];};void f(struct S*P){int i,j,t;for(i=0;in-1;i++)fo 有以下程序: struct S{int n;int a[20];}; void f(struct S*P) { int i,j,t; for(i=0;i<P->n-1;i++) for(j=j+1;j<P->n-1;j++) if(p->a[i]>p->a[j]) {t=P->a[i];p->a[i]=P->a[j];p->a[j]=t} } main() {int i;struct S s{10,{2,3,1,6,8,7,5,4,10,9}}; f(&s); for(i=0;i<s.n;i++)printf("%d",s.a[i]);} 程序运行后的输出结果是( )。A.3B.4C.5D.6
以下程序的输出结果是______。 main () { int x=5,n=3,s,j; for(j=0;j<2;j++) { s=fun(x,n); printf("%d",s); } } fun(int a,int b) { static int n=0,i=2; i=n+1; n=i+a-b; return(n); }A.3 7B.3 5C.3 6D.3 3
有以下程序#include stdio.hvoid fun(int *s,int n1,int n2){ int i,j,t;i=n1; j=n2;while(ij) {t=s[i];s[i]=s[j];s[j]=t;i++;j--;}}main(){ int a[10]={1,2,3,4,5,6,7,8,9,0},k;fun(a,0,3); fun(a,4,9); fun(a,0,9);for(k=0;kl0;k++)printf("%d",a[k]); printf("\n");}程序的运行结果是A.0987654321B.4321098765C.5678901234D.0987651234
有以下程序includevoidfun(int*s,intn1,intn2){inti,j,t; i=n1j=n2; while(i 有以下程序 #include <stdio.h> void fun(int *s,int n1,int n2) { int i,j,t; i=n1 j=n2; while(i<j) {t=s[i];s[i]=s[j];s[j]=t;i++;j--;} } main() { int a[10]={1,2,3,4,5,6,7,8,9,0},k; fun(a,0,3); fun(a,4,9); fun(a,0,9); for(k=0;k<10;k++)printf("%d",a[k]); printf("\n"); } 程序的运行结果是A.987654321B.4321098765C.5678901234D.987651234
有以下程序includeincludevoidfun(char,*s[],intn){char*t;inti,j; for(i= 有以下程序 #include <stdio.h> #include <string.h> void fun(char,*s[],int n) { char *t; int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])) {t=s[i];s[i]:s[j];s[j]=t;} } main() { char *ss[]={"bcc","bbcc","xy","aaaacc","aabcc"}; fun(ss,5); printf("%s,%s\n",ss[0],ss[4]); } 程序的运行结果是A.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc
有以下程序#include stdio.h#include string.hvoid fun(char s[][10],int n){char t; int i,j;for(i=0;in-1;i++)for(j=i+1;jn;j++)/*比较字符串的首字符大小 ,并交换字符串的首字符*/if(s[i][0]s[j][0]) {t=s[i][0];s[i][0]=s[j][0];s[j][0]=t;}}main(){char ss[5][10]={“bcc”,”bbcc”,”xy”,”aaaacc”,”aabcc”};fun(ss,5); printf(“%s,%s\n”,ss[0],ss[4]);}程序的运行结果是( )。A.xy,aaaaccB.aaaacc,xyC.xcc,aabccD.acc,xabcc
main( ){ int a[6]={10,20,30,40,50,60},i;invert(a,0,5);for(i=0;i6;i++) printf(“%d,”,a[i]);printf(“\n”);}invert(int s[ ],int i,int j){ int t;if(iJ){ invert(s,i+1j-1);t=s[i];s[i]=s[j];s[j]=t;}}
单选题有以下程序: #include voidfun(int*s,intn1,intn2) { inti,j,t; i=n1; j=n2; while(i { t=s[i]; s[i]=s[j]; s[j]=t; i++; j--; } } main() { inta[10]={1,2,3,4,5,6,7,8,9,0},k; fun(a,0,3); fun(a,4,9); fun(a,0,9); for(k=0;k printf("%d",a[k]); printf(""); } 程序运行的结果是( )。A0987654321B4321098765C5678901234D0987651234
单选题有以下程序:#include #include void fun(char *s[],int n){ char *t; int i,j; for(i=0;i for(j=i+1;j if(strlen(s[i])strlen(s[j])) { t=s[i]; s[i]=s[j]; s[j]=t; }}main(){ char *ss[]={"bcc","bbcc","xy","aaaacc","aabcc"}; fun(ss,5); printf("%s,%s",ss[0],ss[4]);}程序的运行结果是( )。Axy,aaaaccBaaaacc,xyCbcc,aabccDaabcc,bcc