首页 c语言二级考试编程题库

c语言二级考试编程题库

举报
开通vip

c语言二级考试编程题库c语言二级考试编程题库 ,,,,,,,,,, 1.,,,д?,,,,fun,,,,?,,,,,,,,?,,,,,,,?,?,,??,,,,,,õ,,,C,,,,,,,?,,?,?,,?,,,,?,,,,,,磬 ,,,,,,,?,-1234,,,,,,,,,,,?,,?,,,,?-1234,,,,,,fun,и,,,,,,,ο,,, #include #include long fun ( char *p) { /* ,,,?,,,,ο, */ int i, len, t; /* len?,,,,,,t?,,,...

c语言二级考试编程题库
c语言二级考试编程题库 ,,,,,,,,,, 1.,,,д?,,,,fun,,,,?,,,,,,,,?,,,,,,,?,?,,??,,,,,,õ,,,C,,,,,,,?,,?,?,,?,,,,?,,,,,,磬 ,,,,,,,?,-1234,,,,,,,,,,,?,,?,,,,?-1234,,,,,,fun,и,,,,,,,ο,,, #include #include long fun ( char *p) { /* ,,,?,,,,ο, */ int i, len, t; /* len?,,,,,,t?,,,, */ long x=0; len=strlen(p); if(p[0]=='-') { t=-1; len--; p++; } else t=1; /* ,,,,,,,,,,,,?,?,,??,,,,,, */ while(*p) x = x*10-48+(*p++); return x*t; } main() /* ,,,, */ { char s[6]; long n; printf("Enter a string:\n") ; gets(s); n = fun(s); printf("%ld\n",n); NONO ( ); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i ; char s[20] ; long n ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%s", s) ; n = fun(s); fprintf(wf, "%ld\n", n) ; } fclose(fp) ; fclose(wf) ; } 2.,,,д,,,,fun,,,,,,?,,,,,,,,M,,N,е?,?,,,,,е,,?,,,,,,,,е,,,,,4η?,?,,,?,,С, ,,,,,磬?,,,,,е,,,,?,, W W W W S S S S H H H H ,,,?,,е,,,,,,,,WSHWSHWSH,,? #include #define M 3 #define N 4 void fun(char s[][N], char *b){ int i,j,n=0; for(i=0; i < N;i++) /* ,,,,д,,,,,,,,,?,,, */ { for(j = 0 ; j < M ; j++) { b[n] = s[j][i] ; n = i * M + j + 1; } } b[n]='\0'; } main() { char a[100],w[M][N]={{'W','W','W','W'},{'S','S','S','S'},{'H','H','H','H'}}; int i,j; printf("The matrix:\n"); for(i=0; i #include #define N 80 int fun( char *s) { int k = 1 ; while(*s) { if(*s == ' ') k++ ; s++ ; } return k ; } main() { char line[N]; int num=0; printf("Enter a string :\n"); gets(line); num=fun( line ); printf("The number of word is : %d\n\n",num); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, num ; char line[N], *p ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fgets(line, N, rf) ; p = strchr(line, '\n') ; if(p != NULL) *p = 0 ; num = fun(line) ; fprintf(wf, "%d\n", num) ; } fclose(rf) ; fclose(wf) ; } 4.,,,д,,,,fun,,,,,,?,,,,,,,,,,,,,,ε,,,,,N,,,,,,,,,,,,,,,,,,ã,,,,,,,,,,,,age,,,,,У ,,,,,,0,,9,,,,,,ε,,,,,,,,d[0],У,,,10,,19,,,,,,ε,,,,,,,,d[1],У,,,20,,29,,,,,,ε,,? ,,,,,,d[2],У,,,,,,4,,,,,,,,100,,,,100,,,,,,,,,,,,,,,,,,d[10],У,,,,,,,,,,,,,,, #include #define N 50 #define M 11 void fun( int *a, int *b) { int i, j ; for(i = 0 ; i < M ; i++) b[i] = 0 ; for(i = 0 ; i < N ; i++) { j = a[i] / 10 ; if(j > 10) b[M - 1]++ ; else b[j]++ ; } } double rnd() { static t=29,c=217,m=1024,r=0; r=(r*t+c)%m; return((double)r/m);} main() { int age[N], i, d[M]; for(i=0; i #define N 80 int fun(int a[], int n) { int i, j = 1, k = a[0] ; for(i = 1 ; i < n ; i++) if(k != a[i]) { a[j++]=a[i] ; k = a[i] ; } a[j] = 0 ; return j ; } main() { int a[N]={2,2,2,3,4,4,5,6,6,6,6,7,7,8,9,9,10,10,10,10},i,n=20; printf("The original data :\n"); for(i=0; i #include #define N 80 void fun1(char *w) /* ,,,,,,?,,,,?,,?,,,,?,,,,,,,?,,λ,, */? { int i; char t; t=w[0]; for(i=0;i=2,,λ,,,,,,,,,,,w,?,n-1λ,,,,,,?,,,,?,,,?,,,,磺w??5923,,,,,,,923,,w??923,,,,,23,, #include unsigned fun ( unsigned w ) { if(w>10000) w %= 10000 ; else if(w>1000) w %= 1000 ; else if(w>100) w %= 100 ; else if(w>10) w %=10 ; return w ; } main( ) { unsigned x; printf ( "Enter a unsigned integer number : " ); scanf ( "%u", &x ); printf ( "The original data is : %u\n", x ); if ( x < 10 ) printf ("Data error !"); else printf ( "The result : %u\n", fun ( x ) ); NONO( ); } NONO( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ unsigned x ; int i ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 20 ; i++) { fscanf(rf, "%u", &x) ; fprintf(wf, "%u\n", fun(x)) ; } fclose(rf) ; fclose(wf) ; } 8.,,,,,,,,N,,N,?,?,,,,,,,,,,,,,,,,,,,?,,,,,д,,,,fun(int a[][N],int n),,,,,,?,,,,,,,,,,,,,,,,,,,,,,е,?,,,,n,,,,,,,磬n,,??3,,a,,,,,е,??a= 1 9 7 3 9 7 2 3 8 ,,,,,,,,,a,,,,,е,?? 6 9 8? 4 5 6 12 15 18#include #include #define N 5 int fun ( int a[][N], int n ) { int i, j; for(i = 0 ; i < N ; i++) for(j = 0 ; j <= i; j++) a[i][j] *= n ; } main ( ) { int a[N][N], n, i, j; printf("***** The array *****\n"); for ( i =0; i=3 ); printf("n = %4d\n",n); fun ( a, n ); printf ("***** THE RESULT *****\n"); for ( i =0; i #define N 80 void fun(int *w, int p, int n) { int i, j = 0, b[N] ; for(i = p + 1 ; i < n ; i++) b[j++] = w[i] ; for(i = 0 ; i <= p ; i++) b[j++] = w[i] ; for(i = 0 ; i < n ; i++) w[i]= b[i] ; } 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 #include int fun(char *str) { char *p = str ; int i = 0 ; while(*p) { if(*p != ' ') str[i++] = *p ; p++ ; } str[i] = 0 ; } main() { char str[81]; int n; printf("Input a string:") ; gets(str); puts(str); fun(str); printf("*** str: %s\n",str); NONO(); } NONO() { /* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ char str[81]; int n = 0; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; while(n < 10) { fgets(str, 80, rf); fun(str); fprintf(wf, "%s", str) ; n++ ; } fclose(rf) ; fclose(wf) ; } 11,,,,,д,,,,fun,,,,,,?,,,,,,,,,,,,,?,,,,,,е,M,,,?,ÿ,,,?,,,,,,,,N,,,,,,,,,,,,,,?,,, µ,,?,,,,,fun,и,,,,,,,ο,,,,,,磬,?,,,,,,е,M,,,?,? AAAA BBBBBBB CC ,,,,,,,,?,,,,,,,,,AAAABBBBBBBCC? ,,,,,strcat(a,b),?,,,,?,,?,b,,,,,,?,a,?,β,,,,,??,,,?,,, #include #define M 3 #define N 20 void fun(char a[M][N], char *b){ /* ,,,?,,,,ο, */ int i; *b=0; for(i = 0 ; i < M ; i++) strcat(b, a[i]) ; } main() { char w[M][N]={"AAAA","BBBBBBB","CC"}, a[100]; int i ; printf("The string:\n"); for(i=0; i void fun(int (*s)[10], int *b, int *n, int mm, int nn) { /* ,,,?,,,,ο, */ int i,j,np=0; /* np,,,,b,,,,,?, */ for(i = 0 ; i < nn ; i++) for(j = 0 ; j < mm ; j++) { b[np] = s[j][i] ; np = i * mm + j + 1; } *n=np; } main() { int w[10][10]={{33,33,33,33},{44,44,44,44},{55,55,55,55}},i,j; int a[100]={0}, n=0; printf("The matrix:\n"); for(i=0; i<3; i++) { for(j=0;j<4; j++)printf("%3d",w[i][j]); printf("\n"); } fun(w,a,&n,3,4); printf("The A array:\n"); for(i=0;i void fun(int (*s)[10], int *b, int *n, int mm, int nn){ int i, j, k ; for(i = 0 ; i < mm ; i++) for(j = 0 ; j < nn ; j++) { k = i * nn + j ; b[k] = s[i][j] ; } *n = mm * nn ; } main() { int w[10][10] = {{33,33,33,33},{44,44,44,44},{55,55,55,55}},i,j ; int a[100] = {0}, n = 0 ; printf("The matrix:\n") ; for(i = 0 ; i < 3 ; i++) { for(j = 0 ; j < 4 ; j++) printf("%3d",w[i][j]) ; printf("\n") ; } fun(w, a, &n, 3, 4) ; printf("The A array:\n") ; for(i = 0 ; i < n ; i++) printf("%3d",a[i]);printf("\n\n") ; NONO() ; } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,,*/ FILE *rf, *wf ; int i, j, k ; int w[10][10], a[100], n = 0, mm, nn ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(k = 0 ; k < 5 ; k++) { fscanf(rf, "%d %d", &mm, &nn) ; for(i = 0 ; i < mm ; i++) for(j = 0 ; j < nn ; j++) fscanf(rf, "%d", &w[i][j]) ; fun(w, a, &n, mm, nn) ; for(i = 0 ; i < n ; i++) fprintf(wf, "%3d", a[i]) ; fprintf(wf, "\n") ; } fclose(rf) ; fclose(wf) ; } 14.,,,д,,,,fun,,,,,,?,,,,,,,ж,,?,,,,?,,,?,,,,,,,,,,,1,,,,,,,,,,,YES,,,,,,,0,,,,,, ,,,,,NO,,,,,,,,?,,,z,,v,?,,,?,?, ,,,磬,?,LEVEL,?,,?,,,,?,123312,,,,?,,?, #include #define N 80 int fun(char *str) { int i, j = strlen(str) ; for(i = 0 ; i < j / 2 ; i++) if(str[i] != str[j - i - 1]) return 0 ; return 1 ; } main() { char s[N] ; printf("Enter a string: ") ; gets(s) ; printf("\n\n") ; puts(s) ; if(fun(s)) printf(" YES\n") ; else printf(" NO\n") ; NONO() ; } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i ; char s[N] ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", s) ; if(fun(s)) fprintf(wf, "%s YES\n", s) ; else fprintf(wf, "%s NO\n", s) ; } fclose(rf) ; fclose(wf) ; } 15.N,,,,?,,,,,,,,,,з,,,?,,,,,,,,t,,,,У,h???,,t,,,,,,,,,,д,,,,fun,,,,,,?,,,,,,,?,,,,,,?,,,,,,?,?,,,?,#include #include #define N 8 struct slist { double s; struct slist *next; }; typedef struct slist STREC;double fun( STREC *h ) { double max=h->s; STREC *p; p=h->next; while(p) { if(p->s>max ) max=p->s; p=p->next; } return max; } STREC * creat( double *s) { STREC *h,*p,*q; int i=0; h=p=(STREC*)malloc(sizeof(STREC));p->s=0; while(is=s[i]; i++; p->next=q; p=q; } p->next=0; return h; } outlist( STREC *h) { STREC *p; p=h->next; printf("head"); do { printf("->%2.0f",p->s);p=p->next;} while(p!=0); printf("\n\n"); } main() { double s[N]={85,76,69,85,91,72,64,87}, max; STREC *h; h=creat( s ); outlist(h); max=fun( h ); printf("max=%6.1f\n",max); NONO(); } 16.,,,д,,,, fun,,,,,,,?7,,,?,,,?,,,,?,β,?,,,,,,,,,5,,,?,ASCII,,,,,,?С, ,,,,磬4,,,?,?CEAedca,,,,,,,,,,?CedcEAa #include #include #include int fun(char *s,int num){ char ch ; int i, j ; for(i = 1 ; i < 6 ; i++) for(j = i + 1 ; j < 6 ; j++) { if(*(s + i) < *(s + j)) { ch = *(s + j) ; *(s + j) = *(s +i) ; *(s + i) = ch ; } } } main() { char s[10]; printf(",,,,7,,,?,,,?,:"); gets(s); fun(s,7); printf("\n%s",s); NONO(); } NONO() { /* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ char s[10] ; FILE *rf, *wf ; int i = 0 ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; while(i < 10) { fgets(s,10,rf) ; s[7] = 0 ; fun(s,7); fprintf(wf, "%s\n", s) ; i++ ; } fclose(rf) ; fclose(wf) ; } 17.,,?,?,,,?,,,,,N,,,,,,,,,,,,,,,,,,з,,,,,,,,,,s,У,,,,д,,,,fun,,,,,,?,,,,,,,????? ,?,,,,,,Χ,,,,,,,?,,,,b,,?,,,,,,,У,,,,,Χ,,,,,,,,,,,,,??,?,,,?, ,,,,,,,磬?,,,,,60 69,,,,,,,,,,,,60,,69,,,,,,,???69,?,,,,,,,,60,,,,,,,,? ,,,,,,,н,,,60,,,,low,У,,,69,,,,high,С, #include #define N 16 typedef struct { char num[10]; int s; } STREC; int fun( STREC *a,STREC *b,int l, int h ){ int i,j = 0 ; for(i = 0 ; i < N ; i++) if(a[i].s >= l && a[i].s <= h) b[j++] = a[i] ; return j ; } main() { STREC s[N]={{"GA005",85},{"GA003",76},{"GA002",69},{"GA004",85}, {"GA001",96},{"GA007",72},{"GA008",64},{"GA006",87}, {"GA015",85},{"GA013",94},{"GA012",64},{"GA014",91}, {"GA011",90},{"GA017",64},{"GA018",64},{"GA016",72}}; STREC h[N],tt;FILE *out ; int i,j,n,low,heigh,t; printf("Enter 2 integer number low & heigh : "); scanf("%d%d", &low,&heigh); if ( heigh< low ){ t=heigh;heigh=low;low=t; } n=fun( s,h,low,heigh ); printf("The student's data between %d--%d :\n",low,heigh); for(i=0;ih[j].s) {tt=h[i] ;h[i]=h[j]; h[j]=tt;} for(i=0;i #include void fun(char *s, char t[]) { int i, j = 0 ; for(i = 0 ; i < strlen(s); i++) if(s[i] % 2==0) t[j++] = s[i] ; t[j] = 0 ; } main() { char s[100], t[100]; printf("\nPlease enter string S:"); scanf("%s", s); fun(s, t); printf("\nThe result is: %s\n", t); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ char s[100], t[100] ; FILE *rf, *wf ; int i ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", s) ; fun(s, t) ; fprintf(wf, "%s\n", t) ; } fclose(rf) ; fclose(wf) ; } 19.,,,,fun,?,,,,,,,,a,,b,е,},,}λ,,,,,,,,,γ,?,,,µ,,,,,,,,c,У,,,,,?,,,,,,,a,е,,λ,, ,λ,,,4η,,,,c,?,λ,,,λ,,,b,е,,λ,,,λ,,,4η,,?,,c,,,λ,,,λ,,,? ,,,,,磬a=45,b=12,,,,,øú,,,,c=2415,, #include void fun(int a, int b, long *c) { *c = (b%10)*1000+(a/10)*100+(b/10)*10+a%10;} main() { int a,b; long c; printf("Input a, b:"); scanf("%d%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, a,b ; long c ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d,%d", &a, &b) ; fun(a, b, &c) ; fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ; } fclose(rf) ; fclose(wf) ; } 20,,,,,д,,,,fun,,,,,,?,,,,,,,,,?,,,,,,,,,,,,,,,,?,,,,?,,,?,,,?,,,,,е,?,,,,,,,衣,,,,,磬?,,,,,е,?? 1 3 5 7 9 2 9 9 9 4 6 9 9 9 8 1 3 5 7 0 ,,,,??61,, #include #define M 4 #define N 5 int fun ( int a[M][N] ) { int tot = 0, i, j ; for(i = 0 ; i < N ; i++) { tot += a[0][i] ; tot += a[M-1][i] ; } for(i = 1 ; i < M - 1 ; i++) { tot += a[i][0] ; tot += a[i][N-1] ; } return tot ; } main( ) { int aa[M][N]={{1,3,5,7,9}, {2,9,9,9,4}, {6,9,9,9,8}, {1,3,5,7,0}}; int i, j, y; clrscr(); printf ( "The original data is : \n" ); for ( i=0; i #include #define N 5 double fun ( int w[][N] ){ int i, j, n=0; double sum=0; for ( i =0; i void fun(int a, int b, long *c) { *c=(b%10)*1000+(a%10)*100+(b/10)*10+(a/10);} main() { int a,b; long c; printf("Input a, b:"); scanf("%d,%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, a,b ; long c ; rf = fopen("C:\\WEXAM\\24990001\\in.dat", "r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d,%d", &a, &b) ; fun(a, b, &c) ; fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ; } fclose(rf) ; fclose(wf) ; } 23.,,,д,,,,fun,,,,,,?,,,,,,,,,С,,,,,,lim,,,,,,,,,,,,,aa,,,,,У,,,,,,,,,,,,,,,,?,, ,,,fun,и,,,,,,,ο,,, #include #define MAX 100 int fun(int lim, int aa[MAX]) { /* ,,,?,,,,ο, */ int i,j,k=0; /* ,,,б,k,,,,,,,,,,,,,, */? for(i=2;i<=lim;i++) { /* ,,,,,,,,ж,aa,,,,,,С,,,,,,lim,,,,,,,,,,,, */ for(j = 2 ; j <= (i/2) ; j++) if(i % j == 0) break; if(j > (i/2)) aa[k++] = i; } return k; } main() { int limit, i, sum; int aa[MAX] ; printf(",,,,?,,,,,,"); scanf("%d", &limit); sum=fun(limit, aa); for(i=0 ; i < sum ; i++) { if(i % 10 == 0 && i != 0) printf("\n") ; printf("%5d", aa[i]) ; } NONO(); } NONO() { /* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int limit, i, sum, aa[MAX] ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; fscanf(rf, "%d", &limit); sum=fun(limit, aa); for(i=0 ; i < sum ; i++) fprintf(wf,"%d\n", aa[i]) ; fclose(rf) ; fclose(wf) ; } 24,,?,?,,,?,,,,,N,,,,,,,,,,,,,,,,,з,,,,,,,,,,s,У,,,,д,,,,fun,,,,,,?,,,,,,,,,?????? ,,,,,,,,,,??,,,,b,,?,,,,,,,У,?,,,,,,,,,,,,,??,,,??,,,,,?,,,,,,,,,,,,,,??#include #define N 16 typedef struct { char num[10]; int s; } STREC; int fun( STREC *a, STREC *b ) { int i, j = 0, min=a[0].s ; for(i = 0 ; i < N; i++) { if(min > a[i].s) { j = 0 ; b[j++] = a[i] ; min = a[i].s ; } else if(min == a[i].s) b[j++] = a[i] ; } return j ; } main() { STREC s[N]={{"GA05",85},{"GA03",76},{"GA02",69},{"GA04",85}, {"GA01",91},{"GA07",72},{"GA08",64},{"GA06",87}, {"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91}, {"GA011",91},{"GA017",64},{"GA018",64},{"GA016",72}}; STREC h[N]; int i,n;FILE *out ; n=fun( s,h ); printf("The %d lowest score :\n",n); for(i=0;i #include void fun(char *s, char t[]) { int i, j = 0 ; for(i = 0 ; i < strlen(s); i++) if(s[i] % 2) t[j++] = s[i] ; t[j] = 0 ; } main() { char s[100], t[100]; printf("\nPlease enter string S:"); scanf("%s", s); fun(s, t); printf("\nThe result is: %s\n", t); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ char s[100], t[100] ; FILE *rf, *wf ; int i ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", s) ; fun(s, t) ; fprintf(wf, "%s\n", t) ; } fclose(rf) ; fclose(wf) ; } 26.,,,д,,,,fun,,,,,,?,,,,,,,,,1,,m,,,,,m,,,,,7,,11,,,,,,,,,,,,,,,,,,,b,У,,,,n,,,,,,Щ,,?,,,,,,,,,磬,,m,,??50,,,,,,,,,,7 11 14 21 22 28 33 35 42 44 49#include #define M 100 void fun ( int m, int *a , int *n ){ int i ; *n=0 ; for(i=7 ; i<=m; i++) if((i % 7 == 0) || (i % 11 == 0)) a[(*n)++]=i ;} main( ) { int aa[M], n, k; fun ( 50, aa, &n ); for ( k = 0; k < n; k++ ) if((k+1)%20==0) printf("\n"); else printf( "%4d", aa[k] ); printf("\n") ; NONO( ); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, n, j, k, aa[M], sum ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%d,", &j) ; fun(j, aa, &n) ; sum = 0 ; for(k = 0 ; k < n ; k++) sum+=aa[k] ; fprintf(wf, "%d\n", sum) ; } fclose(fp) ; fclose(wf) ; } 27.,,,д,,,,fun,,,,,,?,,,,,,,,,,,,?,,,,е,?,,,,,,,?,,,0.0005,,,,?,,С,,0.0005,,?,,, ,,/2=1+1/3+(1/3)*(2/5)+,,.+(1*2*,,*n)/(3*5*,,*(2n+1)),,,,,,,к,,,,,,,,,?0.0005,,,,,,,,,,?3.14,,,, #include #include double fun ( double eps) { double s=1,t=1./3; int n=1; while(t>=eps){ s+=t; n++; t=t*n/(2.0*n+1); } return (s*2.0); } main( ) { double x; printf("Input eps:") ; scanf("%lf",&x); printf("\neps = %lf, PI=%lf\n", x, fun(x)); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i ; double x ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%lf", &x) ; fprintf(wf, "%lf\n", fun(x)) ; } fclose(fp) ; fclose(wf) ; } 28,,,д,,,,fun,,,,,,?,,,,,,,,,1,,1000,,,,,,7,,11,,,,,,,,,,7,,11,,,,,,,,,,,,,,,,,,,a, ,?,,,,,,,У,,,,n,,,,,,Щ,,?,,, #include void fun (int *a, int *n) { int i ; *n = 0 ; for(i = 7 ; i < 1000 ; i++) if(((i % 7) == 0 || (i % 11) == 0) && (i % 77) != 0) a[(*n)++] = i ; } main( ) { int aa[1000], n, k ; fun ( aa, &n ) ; for ( k = 0 ; k < n ; k++ ) if((k + 1) % 10 == 0) printf("\n") ; else printf("%5d", aa[k]) ; NONO( ); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ int aa[1000], n, k ; FILE *fp ; fp = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; fun ( aa, &n ) ; for ( k = 0 ; k < n ; k++ ) if((k + 1) % 10 == 0) fprintf(fp, "\n") ; else fprintf(fp, "%5d", aa[k]) ; fclose(fp) ; } 29.,,?,?,,,,,?,,,,,N,,,,,,,,,,,,,,,,,,з,,,,,,,,,,s,У,,,,д,,,,fun,,,,,,?,,,,,,????? ,,,?,,,,,,,?,,,,,?,,,,b,,?,,,,,,,У,,,,,,,,,,,?,,,,,,,,,,,β,n,,,??,,,,,,,,,,?,,,?,#include #define N 12 typedef struct { char num[10]; double s; } STREC; double fun( STREC *a, STREC *b, int *n ){ double t=0 ; int i ; *n = 0 ; for(i = 0 ; i < N ; i++) t = t + a[i].s ; t = t / N ; for(i = 0 ; i < N ; i++) if(a[i].s > t) b[(*n)++] = a[i] ; return t ; } main() { STREC s[N]={{"GA05",85},{"GA03",76},{"GA02",69},{"GA04",85}, {"GA01",91},{"GA07",72},{"GA08",64},{"GA06",87}, {"GA09",60},{"GA11",79},{"GA12",73},{"GA10",90}}; STREC h[N], t;FILE *out ; int i,j,n; double ave; ave=fun( s,h,&n ); printf("The %d student data which is higher than %7.3f:\n",n,ave); for(i=0;i void fun( char *a ) { /* ,,,?,,,,ο, */ char *p,*q; int n=0; p=a; while(*p=='*') /* ,,,,,'*',,,,n */ {n++; p++;} q=a; /* ,,,,,,,,?,,,,,д,,,,,,,,,,,?,,, */ while(*p) { *q=*p; p++;q++; } for(;n>0;n--) /* ,,,β,,n,,'*' */ *q++='*'; *q='\0'; } main() { char s[81],*p; int n=0; printf("Enter a string:\n");gets(s); fun( s ); printf("The string after moveing:\n");puts(s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *in, *out ; int i ; char s[81] ; in = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; out = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(in, "%s", s) ; fun(s) ; fprintf(out, "%s\n", s) ; } fclose(in) ; fclose(out) ; } 31.,,,д?,,,,void fun(char a[],char b[],int n),,,,,,,,,,,?,,?,?,,,?,,,?,,,?,,,,У,a?,,,,?,,?,?,,,?,,,,?,,,,,b,,?,,,,,,,У,n,д,,?,,,,,?, ,,,,,,,磬?,,,?,World,,,,,,,,,3,,,,,,øú,,,,?,,?,,Word,,#include #include #define LEN 20 void fun (char a[], char b[], int n){ strncpy(b, a, n) ; b[n] = 0 ; strcat(b, a + n + 1) ; } main( ) { char str1[LEN], str2[LEN] ; int n ; printf("Enter the string:\n") ; gets(str1) ; printf("Enter the position of the string deleted:") ; scanf("%d", &n) ; fun(str1, str2, n) ; printf("The new string is: %s\n", str2) ; NONO() ; } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ char str1[LEN], str2[LEN] ; int i, n ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s %d", str1, &n) ; fun(str1, str2, n) ; fprintf(wf, "%s\n", str2) ; } fclose(rf) ; fclose(wf) ; } 32.,,,,,,,,,?,,,?,,,,?,,*,š,,,,д,,,,fun,,,,,,?,,,,,,,,?,,,,,*,?,,ö,,,n,,,,,,,n,,,,?,,,,,,*,?,,,,,,,,,,,n,,,,,ô?,,,,,?,,м,,β,,,,*,?,,,,,fun,и,,,,,,,ο,,,? ,,,磬,?, ,е,,,,,?,,********A*BC*DEF*G****,,,,n,,??8,,,,,?,,е,,,,,,,?********A*BC*DEF*G****, ,n,,?,,,,,,,,,,,,?,,д,,,,,,,,,,,,,,C,,,,,,,,,?,,,#include void fun( char *a, int n ) { /* ,,,?,,,,ο, */ int i=0,j,k=0; while(a[k]=='*') k++; /* k?,,,*,?,,,, */ if(k>n) { i=n;j=k; /* ,,,,,,,,?,?k,t,β,,?,?,,,,k-n,,λ,, */ for(; a[j] !=0 ; j++) a[i++]=a[j]; a[i] = 0; } } main() { char s[81]; int n; printf("Enter a string:\n");gets(s); printf("Enter n : ");scanf("%d",&n); fun( s,n ); printf("The string after deleted:\n");puts(s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *in, *out ; int i, n ; char s[81] ; in = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; out = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(in, "%s", s) ; fscanf(in, "%d", &n) ; fun(s,n) ; fprintf(out, "%s\n", s) ; } fclose(in) ; fclose(out) ; } 33.,,,,fun,?,,,,,,,,},,}λ,,,,,,,,,a,,b,,,,,?,,,,,,,,,c,У,,,,,?,,,,,,,a,,,,λ,,,λ, ,,4η,,,c,,,,λ,,,λ,,,b,,,,λ,,,λ,,,4η,,,c,,?,λ,,,λ,,,,,,,,磬a=45 b=12,,,,,,øú,,,,c=5142,, #include void fun(int a, int b, long *c) { *c=(a%10)*1000+(b/10)*100+(a/10)*10+(b%10);} main() { int a,b; long c; printf("Input a, b:"); scanf("%d,%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, a,b ; long c ; rf = fopen("C:\\WEXAM\\24990001\\in.dat", "r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d,%d", &a, &b) ; fun(a, b, &c) ; fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ; } fclose(rf) ; fclose(wf) ; } 34.,,,д,,,,fun,,,,,,?,,,,,,,,,,,,,n,,,,(n,,,,,,,,,5,,9,,,,,,,,,,,,,?,,,,,,, ,,,,,,,,,,磬д,,,,,n,,,,20,,,,,?,,s=0.583333,,?,,,,n,?,?,,,,,,100,, #include double fun(int n) { int i; double sum=0.0; for(i=1; i<=n; i++) if(i%5 == 0 || i%9 == 0) /* ,,5,,9,,, */ sum+=1.0/i; return sum; } main() { int n; double s; printf("\nInput n: "); scanf("%d",&n); s=fun(n); printf("\n\ns=%f\n",s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int n, i ; double s ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d", &n) ; s = fun(n) ; fprintf(wf, "%lf\n", s) ; } fclose(rf) ; fclose(wf) ; } 35.,,д?,,,,,num,,,?,,,,?,,,,,?,,,?,,,,,,,β,?,,max,,,?ô,,,?,,,,?,,,,,,,,,,****,,?,,,,, ,,,?,?,,,,,,fun,и,,,,,,,ο,,, #include #include fun(char(*a)[81],int num,char **max){ /* ,,,?,,,,ο, */ int i,k=0,maxlen; /* k?a,,,,,,,,,,,,,,,,?,,?,,,,?0,,maxlen?,,,, */ maxlen=strlen(a[k]); for(i=1;i maxlen) { maxlen = strlen(a[i]) ; k = i ; } } *max=a[k]; } main() { char ss[10][81],*ps; int n,i=0; printf(",,,,,,,?,?,:"); gets(ss[i]); puts(ss[i]); while(!strcmp(ss[i],"****")==0) { i++; gets(ss[i]); puts(ss[i]); } n=i; fun(ss,n,&ps); printf("\nmax=%s\n",ps); NONO(); } 36.,,,,fun,?,,,,,,,,s,,?,?,,г,,,,?,??,,,,ASCII????,,,,?,,,,,,,,,,,,,,,,,,??,?,,,,γ,?,,? ,?,,,,,t,,?,,,,,,,С, ,,,,磬 ,s,,?,?,,е,,,,,?,,,,ABCDEFG123456,,,,,,,,,?,A,,ASCII,,??,,,,,,,,,,,,,,,,??,?,B,,ASCII?? ?,,,,,,,,,е,,?,?,,,,,,,?,,,,,,??,?,2,,ASCII,,???,,,,,,,,,,,е,,?,???,,,,,,,,,,,,,,??,,4,,,,?,,,,t,,?,,,,,,,е,,,,,,,,246,,,,? #include #include void fun(char *s, char t[]) { int i, j = 0 ; for(i = 0 ; i < strlen(s) ; i += 2) if(s[i] % 2 == 0) t[j++] = s[i] ; t[j] = 0 ; } main() { char s[100], t[100]; printf("\nPlease enter string S:"); scanf("%s", s); fun(s, t); printf("\nThe result is: %s\n", t); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ char s[100], t[100] ; FILE *rf, *wf ; int i ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", s) ; fun(s, t) ; fprintf(wf, "%s\n", t) ; } fclose(rf) ; fclose(wf) ; } 37.,,,,,,,,,?,,,?,,,,?,,*,?,,,,д,,,,fun,,,,,,?,,,,,,?,,?,?,,,,,,β,,,,*,?,,,,,,,?,,,,* ,?,,,,,,β,n,,,,,?,?,?,,,,,β,h,,,,,,?,,,,,,*,??,,,,β,e,,,,,,?,,,,,,*,??,,,,,,д,,,,,, ,,,,,,,,C,,,,,,,,,?,,, ,,,磬,?,,е,,,,,?,, ****A*BC*DEF*G******,,,,,?,?,,е,,,,,,,,A*BC*DEF*G,,? #include void fun( char *a, int n,int h,int e ){ char *p=a ; int j=0,len=0; while(*p) {p++; len++;} while(j void fun( char *a ) { int j =0 ; char *p=a; while(*p) { if(*p != '*') a[j++]=*p ; p++ ; } a[j]=0; } main() { char s[81]; printf("Enter a string:\n");gets(s); fun( s ); printf("The string after deleted:\n");puts(s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *in, *out ; int i ; char s[81] ; in = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; out = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(in, "%s", s) ; fun(s) ; fprintf(out, "%s\n", s) ; } fclose(in) ; fclose(out) ; } 39.,,,,,,,,,?,,,?,,,,?,,*,?,,,,д,,,,fun,,,,,,?,,,,,,,,,,,?,,,,,,*,,,,,,,,,,,,,,,*,,, ,,,,,?,,д,,,,,,,,,,,,,,C,,,,,,,,,?,,,,,fun,и,,,,,,,ο,,, ,,,磬,?,,е,,,,,?,,****A*BC*DEF*G******,,,?,,,,?,,е,,,,,?,,****A*BC*DEF*G,, #include void fun( char *a ) { /* ,,,?,,,,ο, */ int i=0,k; while(a[i]=='*') i++; k=i; while(a[i]!='\0') /* ,,,?,,,,,,?,*,?,,,, */ { if(a[i] != '*') a[k++]=a[i]; i++; } a[k]='\0'; } main() { char s[81]; printf("Enter a string:\n");gets(s); fun( s ); printf("The string after deleted:\n");puts(s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *in, *out ; int i ; char s[81] ; in = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; out = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(in, "%s", s) ; fun(s) ; fprintf(out, "%s\n", s) ; } fclose(in) ; fclose(out) ; } 40.,,,д,,,,fun,,,,,,?,,,,,,,,,,n,?γ,,,,,,,,,,,,,,,?,,,,?,,,?, ,,,,,,,磬5,?γ,?,,,,90.5 72 80 61.5 55,,,,,?,??71.80,, #include float fun ( float *a , int n ) { int i; float ave=0.0; for(i=0; i #include #define N 5 int fun ( int a[][N], int m ) { int i, j; for(i = 0 ; i < N ; i++) for(j = i ; j < N ; j++) a[i][j] *= m ; } main ( ) { int a[N][N], m, i, j; printf("***** The array *****\n"); for ( i =0; i=3 ); printf("m = %4d\n",m); fun ( a ,m ); printf ("THE RESULT\n"); for ( i =0; i #include #define M 81 int fun(char *ss, char c) { int cnt = 0 ; char *p = ss ; while(*p) { if(*p == c) cnt++ ; p++ ; } return cnt ; } main() { char a[M], ch; printf("\nPlease enter a string:"); gets(a); printf("\nPlease enter a char:"); ch = getchar(); printf("\nThe number of the char is: %d\n", fun(a, ch)); NONO ( ); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ int i ; FILE *rf, *wf ; char a[M], b[M], ch ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", a) ; fscanf(rf, "%s", b) ; ch = *b ; fprintf(wf, "%c=%d\n", ch, fun(a, ch)) ; } fclose(rf) ; fclose(wf) ; } 43.,,,,,,,,,?,,,?,,,,?,,*,?,,,,д,,,,fun,,,,,,?,,,,,,,,,?,β,,,,*,,,,,,,,,,,,м,,*,?,??,, ,,,磬,?,,е,,,,,?,,****A*BC*DEF*G******,,,,,?,?,,е,,,,,,,,,,****A*BC*DEF*G,,,?,,д,,,,,,,,,,,,,,C,,,,,,,,,?,,, #include void fun( char *a ) { char *p = a ; while(*p) p++ ; p-- ; while(*p == '*') p-- ; p++ ; *p = 0 ; } main() { char s[81]; printf("Enter a string:\n");gets(s); fun( s ); printf("The string after deleted:\n");puts(s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *in, *out ; int i ; char s[81] ; in = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; out = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(in, "%s", s) ; fun(s) ; fprintf(out, "%s\n", s) ; } fclose(in) ; fclose(out) ; } 44.N,,,,?,,,,,,,,,,з,,,?,,,,,,,,t,,,,У,h???,,t,,,,,,,,,,д,,,,fun,,,,,,?,,,,,,,,,,,,,,,,,?,?,,,?, ,,,,,磬???,,?,,,,85,,76,,69,,85,,91,,72,,64,,87,,,,,,,,,,,,71.625,, #include #include #define N 8 struct slist { double s; struct slist *next; }; typedef struct slist STREC; double fun( STREC *h ) { STREC *p=h->next; /* ,,,,,,,,,,û,д,,,,, */ double av=0.0; /* ,,,,,,,,?,?,?,,,,г,,,, */? int n = 0 ; while(p!=NULL) { /* ,ж,t,,,,,,,, */ av = av + p->s ; /* ,,,,,,,,?,, */ p=p->next; /* ,,,,?,,,,λ,, */ n++; /* ,,,,,1 */ } av /= n ; /* ,,,,,,,?,? */ return av ; /* ,,,?,,,?,? */ } STREC * creat( double *s) { STREC *h,*p,*q; int i=0; h=p=(STREC*)malloc(sizeof(STREC));p->s=0; while(is=s[i]; i++; p->next=q; p=q; } p->next=0; return h; } outlist( STREC *h) { STREC *p; p=h->next; printf("head"); do { printf("->%4.1f",p->s);p=p->next;} while(p!=0); printf("\n\n"); } main() { double s[N]={85,76,69,85,91,72,64,87},ave; STREC *h; h=creat( s ); outlist(h); ave=fun( h ); printf("ave= %6.3f\n",ave); NONO(); } 45.,,,,,,,,,?,,,?,,,,?,,*,?,,,,д,,,,fun,,,,,,?,,,,,,,,?,,,β,,,,*,?,,ö,,,n,,,,,,,n,, ,,,,,,,,*,?,,,,,,,n,,,,,ô?,,,,?,?,,м,,,,,,*,?,,,? ,,,磬,?, ,е,,,,,?,,****A*BC*DEF*G******,,,,n,,??4,,,,,?,?,,е,,,,,,,,,,****A*BC*DEF*G******?,,,,n,,??7,,,,,?,,е,,,,,,,?****A*BC*DEF*G******,,N,,?,,,,,,,,,,,,?,,д,,,,,,,,,,,,,,C,,,,,,,,,?,,,#include void fun( char *a,int n ) { char *p=a ; int j=0; while(*p) p++; p--; /* ,?,?,,, */ while(*p == '*') p--; /* ,?,,,'*' */? p++; while(j #include long jc(int n) { long s = 1 ; int i ; for(i = 1 ; i <= n ; i++) s *= i ; return s ; } double fun(double x , int n){ double s = 1.0, y = x ; int i ; for(i = 1 ; i <= n ; i++) { s += y / (double)jc(i) ; y *= x ; } return s ; } main() { printf("%f\n", fun(0.3,10)); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, n ; double s, x ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%lf,%d", &x, &n) ; s = fun(x, n) ; fprintf(wf, "%f\n", s) ; } fclose(fp) ; fclose(wf) ; } 47.,,д,,,,fun,,,,?,,,,,,,,,,,,,,,,м,,,,,S=1/(1*2)+1/(2*3)+,,+1/(n(n+1)),,,,,磬n=10,,,,,,,??,,0.909091,, #include double fun( int n ) { double s = 0.0 ; int i ; for(i = 1 ; i <= n ; i++) s = s + 1.0 / (i * (i + 1)) ; return s ; } main() /* ,,,, */ { printf("%f\n", fun(10)); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, n ; double s ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%d", &n) ; s = fun(n) ; fprintf(wf, "%f\n", s) ; } fclose(fp) ; fclose(wf) ; } 48.,,,д,,,,fun,,,,,,?,,,,,,,,С,,,β,n,,,,,3,,7,,,,,,,,,,,,,,,,,,,,,,,?,,,?,?,,,?, ,,,,,,n?1000,,,,,,,,,,?,,s=153.909064,,? #include #include double fun( int n) { double sum=0.0; int i; for(i=21; i<=n; i++) if((i % 3==0) && (i % 7==0)) sum+=i; return sqrt(sum) ; } main() /* ,,,, */ { printf("s =%f\n", fun ( 1000) ); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, n ; float s; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%d", &n) ; s = fun(n) ; fprintf(wf, "%f\n", s) ; } fclose(fp) ; fclose(wf) ; } 49.,,д,,,,fun,,,,,,,,,,,,,,?,,,,P,,?,,,,,,,,?,?,,?,m,,n?},,,,,,,,,,,,m>n,,? P=m!/(n!(m-n)!) ,,,磬m=12,n=8,,,,,,н,,?495.000000,,#include long jc(int m) { long s=1; int i ; for(i=1;i<=m;i++) s=s*i ; return s; } float fun(int m, int n) { float p; p=1.0*jc(m)/jc(n)/jc(m-n) ; return p; } main() /* ,,,, */ { printf("P=%f\n", fun (12,8)); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, m, n ; float s; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%d,%d", &m, &n) ; s = fun(m, n) ; fprintf(wf, "%f\n", s) ; } fclose(fp) ; fclose(wf) ; } 50.,,,,,,,,,?,,,?,,,,?,,*,?,,,,д,,,,fun,,,,,,?,,,,,,,,,?,,е,,õ,*,,,,,,,,м,,β,,,,*,? ?,,,? ,,,磬,?,,е,,,,,?,,****A*BC*DEF*G******,,,,,?,?,,е,,,,,,,,,, A*BC*DEF*G******,,,?,,д,,,,,,,,,,,,,,C,,,,,,,,,?,,,#include void fun( char *a ) { int j=0; char *p = a ; while(*p == '*') p++ ; while(*p) { a[j++] = *p ; p++; } a[j]=0 ; } main() { char s[81]; printf("Enter a string:\n");gets(s); fun( s ); printf("The string after deleted:\n");puts(s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *in, *out ; int i ; char s[81] ; in = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; out = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(in, "%s", s) ; fun(s) ; fprintf(out, "%s\n", s) ; } fclose(in) ; fclose(out) ; } 51.,,,д,,,,fun,,,,,,,,,,,,,,,,,,,,,,,,,,,,,е,,?,,,,,?k,,?,?,,,,,С,,,,,,,,,,,,,,,,磬876 675 896 101 301 401 980 431 45 1 777,,,,,,,,,?6,,980 #include int fun(int *s, int t, int *k) { int i, pos = 0, max = *s ; for(i = 1 ; i < t ; i++) { if(max < *(s + i)) { max = *(s + i) ; pos = i ; } } *k = pos ; } main( ) { int a[10]={876,675,896,101,301,401,980,431,451,777}, k ; fun(a, 10, &k) ; printf("%d, %d\n", k, a[k]) ; NONO( ) ; } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ int a[10], i, k, j ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { for(j = 0 ; j < 10 ; j++) fscanf(rf, "%d", &a[j]) ; fun(a, 10, &k) ; fprintf(wf, "%d,%d\n", k, a[k]) ; } fclose(rf) ; fclose(wf) ; } 52.,,д,,,,fun,,,,?,,,,,,,,Fibonacci,,,,,д,,,t,,,,С,,?,,,,,,,,,,??,,,,,Fibonacci,,,,F(n),?,,,?,, F(0)=0, F(1)=1 F(n)=F(n-1)+F(n-2) ,,,,,磺t=1000,,,,,,,??,,1597,, #include #include int fun( int t) { int f0 = 0, f1 = 1, f ; do { f = f0 + f1 ; f0 = f1 ; f1 = f ; } while(f < t) ; return f ; } main() /* ,,,, */ { int n; n=1000; printf("n = %d, f = %d\n",n, fun(n)); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, n, s ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%d", &n) ; s = fun(n) ; fprintf(wf, "%d\n", s) ; } fclose(fp) ; fclose(wf) ; } 53.,,,д,,,,fun,,,,,,,,,,,,,,,,x,0.97,,,,ж,,,,,,?,,?,, |sn-sn-1|<0.000001??,, Sn=1+0.5x+(0.5(0.5-1)/2!*x2+,,+(0.5)(0.5-1)(0.5-2),,(0.5-n+1))/n!*xn ,,,,,,,,,,磬д,,,,,x,,,,0.21,,,,,?,,s=1.100000,,#include #include double fun(double x) { int n=1; /* ,,,,,,*/? double sn=1; /* ,,,,,*/ double xn=1,xn1=0; /*x,,n?,,,,x,,n-1?;*/ while(fabs(xn-xn1)>=0.000001)/*,,,?,,,,,,,,,*/ { xn=xn*x*(0.5-n+1)/n; /*,,,,,?,,,,xn=(xn-1)*x*(0.5-n+1)/n*/ n+=1; sn+=xn; /*sn,,,,,xn*/ } return(sn); } main() { double x,s; printf("Input x: "); scanf("%lf",&x); s=fun(x); printf("s=%f\n",s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i ; double s, x ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%lf", &x) ; s = fun(x) ; fprintf(wf, "%lf\n", s) ; } fclose(rf) ; fclose(wf) ;} 54.,,,,fun,?,,,,,,,,s,,?,?,,,,?,??,,,,?,,,,,,,,??,?,,γ,,?,,,,,t,?,?,,,,,С, ,,,,,磬s,,?,?,,е,,,,,?,,,,ABCDEFGHIJK,,,,,,t,,?,,,,,е,,,,,,,,,,BDFHJ,,,,?#include #include void fun(char *s, char t[]){ int i, j = 0 ; for(i = 1 ; i < strlen(s); i+=2) t[j++] = s[i] ; t[j] = 0 ; } main() { char s[100], t[100]; printf("\nPlease enter string S:"); scanf("%s", s); fun(s, t); printf("\nThe result is: %s\n", t); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ char s[100], t[100] ; FILE *rf, *wf ; int i ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", s) ; fun(s, t) ; fprintf(wf, "%s\n", t) ; } fclose(rf) ; fclose(wf) ; } 55,,,,,д,,,,fun,,,,,,,,,,,,,,,,β,m,,m,,k,,,,,,,,,xx,?,?,,,,,,,С,,,,,,,,,磬 ,17,,5,,,,,,,19,,23,,29,,31,,37,,,,,,fun,и,,,,,,,ο,,,? #include void fun(int m, int k, int xx[]){ /* ,,,?,,,,ο, */ int i, j=1, t=m+1; while(j<=k) { /* ,,,,,,,,ж,,,,,,?,,,,,xx,, */ for(i = 2 ; i < t; i++) if(t % i==0) break; if(i==t) { xx[j-1] = i; j++; } t++; } } } main() { int m, n, zz[1000] ; printf( "\nPlease enter two integers:") ; scanf("%d%d", &m, &n ) ; fun( m, n, zz) ; for( m = 0 ; m < n ; m++ ) printf("%d ", zz[m]) ; printf("\n") ; NONO( ) ; } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ int m, n, zz[1000], i ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d %d", &m, &n) ; fun(m, n, zz) ; for( m = 0 ; m < n ; m++ ) fprintf(wf, "%d ", zz[m]) ; fprintf(wf, "\n") ; } fclose(rf) ; fclose(wf) ; } 56,,,,,,fun,?,,,,,,,,},,}λ,,,,,,,,,a,,b,,,,γ,?,,,,,,,,,c,С,,,,,?,,,,,,,a,,,,λ,,, λ,,,4η,,,c,,?,λ,,,λ,,,b,,,,λ,,,λ,,,4η,,,c,,,,λ,,,λ,,,,,,,,磬a=45,,b=12,,,,,,øú,,,,c=1524,, #include void fun(int a, int b, long *c) { *c=(b/10)*1000+(a%10)*100+(b%10)*10+(a/10);} main() { int a,b; long c; printf("Input a, b:"); scanf("%d,%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, a,b ; long c ; rf = fopen("C:\\WEXAM\\24990001\\in.dat", "r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d,%d", &a, &b) ; fun(a, b, &c) ; fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ; } fclose(rf) ; fclose(wf) ; } 57.?,,?,?,,,š,8,?γ,,,,,,,,,,,,,?,8,?γ,?,,,,,,,,,,,и,,,,,д,,,,fun,,,??????,,,,,,,,,,,,,,,?,?,,,,?,,ave,,,,С, ,,,磬???,,?,,,,85.5,76,69.5,85,91,72,64.5,87.5,,,,,,,,,,,,,78.875,, #include #define N 8 typedef struct { char num[10]; double s[N]; double ave; } STREC; void fun(STREC *a) { int i ; for(i = 0 ; i < N ; i++) a->ave = a->ave + a->s[i] ; a->ave /= N ; } main() { STREC s={"GA005",85.5,76,69.5,85,91,72,64.5,87.5}; int i; fun( &s ); printf("The %s's student data:\n", s.num); for(i=0;i void fun ( int x, int pp[], int *n ){ int i; *n=0; for(i=1; i <= x; i++) if((x % i== 0) && (i % 2)) pp[(*n)++]=i;} main( ) { int x, aa[1000], n, i ; printf( "\nPlease enter an integer number:\n" ) ; scanf("%d", &x) ; fun(x, aa, &n ) ; for( i = 0 ; i < n ; i++ ) printf("%d ", aa[i]) ; printf("\n") ; NONO( ) ; } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ int x, aa[1000], n, i, j ; FILE *fp ; fp = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(j = 0 ; j < 10 ; j++) { x = 30 + j ; fun(x, aa, &n) ; for(i = 0 ; i < n ; i++) fprintf(fp, "%d ", aa[i]) ; fprintf(fp, "\n") ; } fclose(fp) ; } 59.m,,,,?,,,,,,score,,,,,У,,,,д,,,,fun,,,?,,,,,,,,,,,,,,,?,,,,,,,?,,,,?,,,?,,,,,,,,,,??,,,,,,below,,?,,,,,,,С, ,,,,,磬score,,,,,е,,,,?,,10,,20,,30,,40,,50,,60,,70,,80,,90,,,,,,,?,,,,,,,,,4,,below,е,,,,?,,10,,20,,30,,40,,?? #include #include int fun(int score[], int m, int below[]) { float av=0.0 ; int i, j=0 ; for(i=0; iscore[i]) below[j++]=score[i]; return j; } main( ) { int i, n, below[9] ; int score[9] = {10, 20, 30, 40, 50, 60, 70, 80, 90} ; n = fun(score, 9, below) ; printf( "\nBelow the average score are: " ) ; for (i = 0 ; i < n ; i++) printf("%d ", below[i]) ; NONO() ; } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ int i, j, n, below[10], score[10] ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { for(j = 0 ; j < 10 ; j++) fscanf(rf, "%d", &score[j]) ; n = fun(score, 10, below) ; for(j = 0 ; j < n ; j++) fprintf(wf, "%d ", below[j]) ; fprintf(wf, "\n") ; } fclose(rf) ; fclose(wf) ; } 60.,,,,,,,,N*N,?,?,,,,,,,,,,,,,,,,,,,?,,,,,д,,,,fun(int a[][N]),,,,,,?,,,,,,,,,,,,,,,,,,,,,,е,?,,,,ó,0,,,,,磬a,,,,,е,??,, 9 7 3 8 5 6 ,,,,,,,,,a,,,,,е,??? 0 9 7 0 0 8 0 0 0 #include #include #define N 5 int fun ( int a[][N] ) { int i, j; for(i = 0 ; i < N ; i++) for(j = 0 ; j <= i; j++) a[i][j] = 0 ; } main ( ) { int a[N][N], i, j; printf("***** The array *****\n"); for ( i =0; i int fun(int n) { int s = 0, i ; for(i = 2 ; i < n ; i++) if(n % i == 0) s +=i ; return s ; } main() { int n,sum; printf("Input n: "); scanf("%d",&n); sum=fun(n); printf("sum=%d\n",sum); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, n, sum ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d", &n) ; sum = fun(n) ; fprintf(wf, "%d=%d\n", n, sum) ; } fclose(rf) ; fclose(wf) ; } 62.,,,д?,,,, void fun(char *tt,int pp[]),,,,,,,tt,,?,?,,С,a,,,,,,z,, 26,,Сд,,?,,,,,,??,,,,4η,,,pp,,?,,,,,С, ,,,,,,,,,磬,?,abcdefgabcdeabc,,,,,,,,,,,,,,,,3 3 3 2 2 1 1 0 0 0 0 0 0 0 0 0 0 0? 0 0 0 0 0 ,, #include #include void fun(char *tt, int pp[]) { char *p = tt ; int i ; for(i = 0 ; i < 26 ; i++) pp[i] = 0 ; while(*p) { if(*p >= 'a' && *p <= 'z') pp[*p - 'a'] += 1 ; p++ ; } } main( ) { char aa[1000] ; int bb[26], k, n ; printf( "\nPlease enter a char string:" ) ; scanf("%s", aa) ; fun(aa, bb ) ; for ( k = 0 ; k < 26 ; k++ ) printf ("%d ", bb[k]) ; printf( "\n" ) ; NONO ( ) ; } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ char aa[1000] ; int bb[26], k, n, i ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", aa) ; fun(aa, bb) ; for ( k = 0 ; k < 26 ; k++ ) fprintf (wf, "%d ", bb[k]) ; fprintf(wf, "\n" ) ; } fclose(rf) ; fclose(wf) ; } 63.,,д,,,,fun,,,,?,,,,,,,,,,,,,,,,,,?,,,,,?,cos(x)-x=0,,?,,,,, Xn+1=cos(xn) ,,,,,,,,?, ,,1,,,x1,,??0.0,, ,,2,,x0=x1,,,x1,,?,,,,x0,, ,,3,,x1=cos(x0),,,,,?,,,µ,x1,,,,4,,,,x0-x1,?,,?С,,0.000001,,?,в,,裨5,,,,,,,,?,в,,裨2,,,,,,5,,,,,,x1,,,,,,,cos(x)-x=0,,?,,,,,,,?,,,,?,,,?, ,,,,,,,,, Root=0.739085,, #include #include float fun() { float x0, x1=0.0; do { x0=x1; x1=cos(x0); } while(fabs(x0-x1)>0.000001); return x1; } main() { printf("Root =%f\n", fun()); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *wf ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; fprintf(wf, "%f\n", fun()) ; fclose(wf) ; } 64.,,,,fun,?,,,,,,,,a,,b,е,},,}λ,,,,,,,,,γ,?,,,µ,,,,,,,,c,У,,,,,?,,,,,,,a,е,,λ,, ,λ,,,4η,,,,c,,,λ,,,λ,,,b,е,,λ,,,λ,,,4η,,?,,c ,?,λ,,,λ,,,? ,,,,,磺a=45 b=12,,,,,øú,,,,c=5241,,#include void fun(int a, int b, long *c){ *c=(a%10)*1000+(b%10)*100+(a/10)*10+(b/10); } main() { int a,b; long c; printf("Input a, b:"); scanf("%d%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, a,b ; long c ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d,%d", &a, &b) ; fun(a, b, &c) ; fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ; } fclose(rf) ; fclose(wf) ; } 65,,,д,,,,fun,,,,,,,,,,,ss,,?,?,,,,,,,,?,?,,,,λ,,,,,,?? ?,,?,,д,,,,,λ,,,,,,,,,?,,,,?,,,,,,,,,,,,,,磬?abc4EFg,,,,,,,,,aBc4EFg,,,,? #include #include void fun( char *ss ) { char *p = ss ; int i = 0 ; while(*p) { if((i % 2) && (*p >= 'a' && *p <= 'z')) *p -= 32 ; p++ ; i++ ; } return ss ; } void main( void ) { char tt[51]; printf( "\nPlease enter an character string within 50 characters:\n" ); gets( tt ); printf( "\n\nAfter changing, the string\n \"%s\"", tt ); fun(tt) ; printf( "\nbecomes\n \"%s\"", tt ); NONO(); } NONO() { /* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ char tt[51], ch; FILE *rf, *wf ; int len, i=0 ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; while(i < 10) { fgets( tt, 50, rf ); len = strlen(tt) - 1 ; ch = tt[len] ; if(ch == '\n' || ch == 0x1a) tt[len] = 0 ; fun(tt); fprintf( wf, "%s\n", tt ); i++ ; } fclose(rf) ; fclose(wf) ; } 66.,,,д?,,,, void fun(int tt[M][N],int pp[N]),tt?,,?,,M,,N,е?,?,,,,,, ,?,,,,ÿ,,,,,,С,,,,,,?4η,,,pp,,???,,,,,У,,,?,,,,,е,,,,,,,,,,,,и,,衣#include #define M 3 #define N 4 void fun ( int tt[M][N], int pp[N] ){ int i,j, min, k ; for(i = 0 ; i < N ; i++) { min = tt[0][i] ; k = 0 ; for(j = 1 ; j < M ; j++) if(min > tt[j][i]) { min=tt[j][i] ; k = j ; } pp[i] = tt[k][i] ; } } main( ) { int t [ M ][ N ]={{22,45, 56,30}, {19,33, 45,38}, {20,22, 66,40}}; int p [ N ], i, j, k; printf ( "The original data is : \n" ); for( i=0; i int fun(int array[3][3]) { int i,j,arr[3][3] ; memcpy(arr, array, 9*sizeof(int)) ; for(i = 0 ; i < 3 ; i++) for(j = 0 ; j < 3 ; j++) array[i][j] = arr[j][i] ;} main() { int i,j; int array[3][3]={{100,200,300}, {400,500,600}, {700,800,900}}; for (i=0;i<3;i++) { for (j=0;j<3;j++) printf("%7d",array[i][j]); printf("\n"); } fun(array); printf("Converted array:\n"); for (i=0;i<3;i++) { for (j=0;j<3;j++) printf("%7d",array[i][j]); printf("\n"); } NONO(); } 68,,,,д?,,,,ú,,,,,,,,,?,,,?2,,,?,,,,,?,,,?,,г,,??,,,,,,,磬,,,,,,,,?,?,,asd asasdfg asd as zx67 asd mklo,,,,,?,?as,,,,,,,6,,? #include #include int fun(char *str,char *substr){ int cnt = 0 ; char *p = str, *q ; while(*p) { q = strstr(p, substr) ; if(q == NULL) break; p = q + strlen(substr) ; cnt++ ; } return cnt ; } main() { char str[81],substr[3]; int n; printf(",,,,,,,?,: "); gets(str); printf(",,,,,,,?,: "); gets(substr); puts(str); puts(substr); n=fun(str,substr); printf("n=%d\n",n); NONO(); } 69.,,,д,,,,fun,,,,,,,,,,,,,,,,2λС,,,,,,λ,,,,,,,,,,,,,?,,,,,?,,,, ,,,磺,,,,,?1234.567,,,,,,, 1234.570000,, ,,,,,?1234.564,,,,,,, 1234.560000,, #include float fun ( float h ) { long w ; w = h * 100 + 0.5 ; return (float) w / 100 ;} main( ) { float a; printf ("Enter a: "); scanf ( "%f", &a ); printf ( "The original data is : " ); printf ( "%f \n\n", a ); printf ( "The result : %f\n", fun ( a ) ); NONO( ); } NONO( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ int i ; float a ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 20 ; i++) { fscanf(rf, "%f", &a) ; fprintf(wf, "%f\n", fun(a)) ; } fclose(rf) ; fclose(wf) ; } 70.,,,,,?,?,,,?,,,,,,,,N,,,,,,,,,,,,,,a,,,,,,,,,С,,,,д,,,,fun,,,???????,,,,,,,?,,,,,,,,,,?,,,,,,βη,,,,,,,???,?,,?,,,,,,,,, #include #include #define N 10 typedef struct ss { char num[10]; int s; } STU; fun( STU a[], STU *s ) { int i, min = a[0].s, j = 0; for(i = 1 ; i < N ; i++) if(min > a[i].s) { /* ,,,,,,,min,,,,,,,,, */ j = i ; /* ,,?λ,, */ min = a[i].s ; /* ,,,?,?,?,,min */ } *s = a[j] ; } main ( ) { STU a[N]={ {"A01",81},{"A02",89},{"A03",66},{"A04",87},{"A05",77}, {"A06",90},{"A07",79},{"A08",61},{"A09",80},{"A10",71} }, m ; int i; printf("***** The original data *****\n"); for ( i=0; i< N; i++ )printf("No = %s Mark = %d\n", a[i].num,a[i].s); fun ( a, &m ); printf ("***** THE RESULT *****\n"); printf ("The lowest : %s , %d\n",m.num, m.s); NONO( ); } NONO( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; STU a[N], m ; int i ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10; i++) fscanf(rf, "%s %d", a[i].num, &a[i].s) ; fun(a, &m) ; fprintf (wf, "The lowest : %s, %d\n", m.num, m.s) ; fclose(rf) ; fclose(wf) ; } 71,,,,,,fun,?,,,,,,,,s,,?,?,,,,?,??,,,,ASCII??,,,,,,?,,,s,?,?,,,,,,,?,?,,γ,,??,,,,,t,,?,,,,,,,С, ,,,,磬 ,s,,?,?,,е,,,,,?,,,,ABCDEFG12345,,,,,,,,,?,C,,ASCII,,??,,,,,,,,,,,е,,?,??,,,,,,,,,,?,,?,1,,ASCII,,??,,,,,,,,,,,е,,?,??,,,,,,,,,,,,,,,,,,,,,,,?,?? ,,,t,,?,,,,,,,е,,,,,,,,BDF12345,,,,? #include #include void fun(char *s, char t[]) { int i, j = 0 ; for(i = 0 ; i < strlen(s) ; i++) if(!((i % 2) ==0 && (s[i] % 2))) t[j++] = s[i] ; t[j] = 0 ; } main() { char s[100], t[100]; printf("\nPlease enter string S:"); scanf("%s", s); fun(s, t); printf("\nThe result is: %s\n", t); NONO(); } NONO( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ char s[100], t[100] ; FILE *rf, *wf ; int i ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", s) ; fun(s, t) ; fprintf(wf, "%s\n", t) ; } fclose(rf) ; fclose(wf) ; } 72.,,,,fun,?,,,,,,,,s,,?,?,,г,,,,?,?,,,,,,ASCII???,,,,,,?,,,,,,,,,,,,,,?,,,,,,,,??,?,,,,γ?,?,,,?,,,,,t,,?,,,,,,,С, ,,,,,磬s,,?,?,,е,,,,,?,,,,ABCDEFG12345,,,,,,,,,?,A,,ASCII,,?,,?,,,,,,,,,, ?,,?,??,,,,,,,,,,,?,?,1,,ASCII,,??,,,,,,,,,,,,,е,,?,??,,,,,,,,,,,,,,,,,,4,,,,?,,?? ,,t,,?,,,,,,,е,,,,,,,,,,135,,,,? #include #include void fun(char *s, char t[]) { int i, j = 0 ; for(i = 1 ; i < strlen(s) ; i += 2) if(s[i] % 2) t[j++] = s[i] ; t[j] = 0 ; } main() { char s[100], t[100]; printf("\nPlease enter string S:"); scanf("%s", s); fun(s, t); printf("\nThe result is: %s\n", t); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ char s[100], t[100] ; FILE *rf, *wf ; int i ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", s) ; fun(s, t) ; fprintf(wf, "%s\n", t) ; } fclose(rf) ; fclose(wf) ; } 73.,,,д,,,,fun,,,,,,,,,,,,?,,2*M,,,,,?,,,,,,,,,,,?,,,,?,,,,,,,,??,,ú,,, #include #define M 4 fun (int a[][M]) { int i, j, max=a[0][0]; for(i=0; i<2; i++) for(j=0; j #include #define N 10 typedef struct ss { char num[10]; int s; } STU;fun( STU a[], STU *s ) { int i, max = a[0].s, j = 0; for(i = 1 ; i < N ; i++) if(max < a[i].s) { j = i ; max = a[i].s ; } *s = a[j] ; } main ( ) { STU a[N]={ {"A01",81},{"A02",89},{"A03",66},{"A04",87},{"A05",77}, {"A06",90},{"A07",79},{"A08",61},{"A09",80},{"A10",71} }, m ; int i; printf("***** The original data *****\n"); for ( i=0; i< N; i++ )printf("No = %s Mark = %d\n", a[i].num,a[i].s); fun ( a, &m ); printf ("***** THE RESULT *****\n"); printf ("The top : %s , %d\n",m.num, m.s); NONO( ); } NONO( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; STU a[N], m ; int i ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10; i++) fscanf(rf, "%s %d", a[i].num, &a[i].s) ; fun(a, &m) ; fprintf (wf, "The top : %s, %d\n", m.num, m.s) ; fclose(rf) ; fclose(wf) ; } 75,,,,,д?,,,,fun(char *s),,,,,,?,,,,,,s,,?,?,,е,,,,,,,,ã,,,,磺,?,,,,,е,,?,?,,abcdefg,,,,,,øú,,,,,,е,,,,,?,,gfedcba,,#include #include #define N 81 fun ( char *s ) { char b[N] ; int i = 0, j ; memset(b, 0, N) ; for(j = strlen(s) - 1 ; j >= 0 ; j--) b[i++] = s[j] ; strcpy(s, b) ; } main( ) { char a[N]; printf ( "Enter a string : " ); gets ( a ); printf ( "The original string is : " ); puts( a ); fun ( a ); printf("\n"); printf ( "The string after modified : "); puts ( a ); NONO( ); } NONO( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ int i ; char a[N] ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", a) ; fun(a) ; fprintf(wf, "%s\n", a) ; } fclose(rf) ; fclose(wf) ; } 76.,,,д,,,,fun,,,,,,,,,,?,??,,,,,,,,,,,,,,,,,?,,,,,,,,,,?,,,,,?,,,,,,,,,,?,,,,,βδ,, ?,,,,,,,,,е,?,,,,,,,,,и,,衣 ,,,,,,x,,,,,,,,n,,x,е,,,,,,,max,,,,,,?,,index,,,,,,?,,,,,,?,,?, #include #include void fun(int a[], int n , int *max, int *d ){ int i ; *max=a[0];*d = 0 ; /* ,,,,,,?,1,,,,,?,,?,,,,,?,,*max */? for(i = 1; i < n; i++) if(*max < a[i]) { /* ,ж,*max,,,С,,,,? */ *max = a[i]; /* ,,,?,,,,?,,?,,*max */ *d = i ; /* ,,?,?, */ } } main() { int i, x[20], max , index, n = 10; randomize() ; for (i=0;i < n;i++) {x[i] = rand()%50; printf("%4d", x[i]) ; } printf("\n"); fun( x, n , &max, &index); printf("Max =%5d , Index =%4d\n",max, index ); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, x[20], max , index, n = 10, j ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { for(j = 0 ; j < n ; j++) fscanf(fp, "%d,", &x[j]) ; fun( x, n , &max, &index); fprintf(wf, "Max=%d,Index=%d\n", max, index) ; } fclose(fp) ; fclose(wf) ; } 77.,,,д,,,,fun,,,,,,,,,,,,},,,?,,l,,,,,,ÿ?,,,strcat,,,,,,,,p2,,?,,,?,l,,p1,?,?,,,?,,,,,磬,?,,,,,,,,,},,,?, FirstString--- SecondString ,,,,,,, FirstString---SecondString #include void fun(char p1[], char p2[]) { char *p=p1; while(*p)p++; while(*p2) *p++=*p2++; *p=0; } main() { char s1[80], s2[40] ; printf("Enter s1 and s2:\n") ; scanf("%s%s", s1, s2) ; printf("s1=%s\n", s1) ; printf("s2=%s\n", s2) ; printf("Invoke fun(s1,s2):\n") ; fun(s1, s2) ; printf("After invoking:\n") ; printf("%s\n", s1) ; NONO() ; } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ int i ; FILE *rf, *wf ; char s1[80], s2[40] ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%s", s1) ; fscanf(rf, "%s", s2) ; fun(s1, s2) ; fprintf(wf, "%s\n", s1) ; } fclose(rf) ; fclose(wf) ; } 78.,,,,,,,,,?,,,?,,,,?,,*,š,,,,д,,,,fun,,,,,, ,,,,,,,β,,,,*,,,,,,,,?,,,,,,,*,,,,,,,,β,p,?,?,,,?,,,,,,?,,,,?,,,,,д,,,,,,,,,,,,,,C,, ,,,,,,,?,,, ,,,磬,?,,е,,,,,?,,****A*BC*DEF*G******,,,,,?,?,,е,,,,,,,,,,ABCDEFG******,,?#include void fun( char *a, char *p ){ char *q=a; int j=0; while(*q && q int isP(int m) { int j, tag = 0 ; for(j = 2 ; j < m && !tag ; j++) if(m % j == 0) tag = 1 ; return tag ; } void fun( int m, int *k, int xx[] ){ int i, cnt = 0 ; for(i = 2 ; i < m ; i++) if(isP(i)) xx[cnt++] = i ; *k = cnt ; } main() { int m, n, zz[100]; printf( "\nPlease enter an integer number between 10 and 100: " ); scanf( "%d", &n ); fun( n, &m, zz ); printf( "\n\nThere are %d non-prime numbers less than %d:", m, n ); for( n = 0; n < m; n++ ) printf( "\n %4d", zz[n] ); NONO(); } NONO() { /* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ int m, n, zz[100]; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; fscanf( rf, "%d", &n ); fun( n, &m, zz ); fprintf(wf, "%d\n%d\n", m, n ); for( n = 0; n < m; n++ ) fprintf(wf, "%d\n", zz[n] ); fclose(rf) ; fclose(wf) ; } 80.,,,,fun,?,,,,,,,,a,,b,е,},,}λ,,,,,,,,,γ,?,,,µ,,,,,,,,c,С,,,,,?,,,,,,,a,е,,λ,, ,λ,,,4η,,,,c,,,λ,,,λ,,,b,е,,λ,,,λ,,,4η,,?,,c ,?,λ,,,λ,,,? ,,,,,磬a=45, b=12,,,,,øú,,,, c=4251,,#include void fun(int a, int b, long *c){ *c=(a/10)*1000+(b%10)*100+(a%10)*10+(b/10); } main() { int a,b; long c; printf("Input a, b:"); scanf("%d%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, a,b ; long c ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d,%d", &a, &b) ; fun(a, b, &c) ; fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ; } fclose(rf) ; fclose(wf) ; } 81.,,,д,,,,fun,,,,,?,,,,,,,,,B=A+A,,,,,,,,,,A,,,,A,,??,ã,,,,,,,,,B,С,,,,,,,,,mai n,,,,,,,,, ,,,,,,,,,,,磬?,,,,,,?,þ,,,?,, 1 2 3 1 4 7 4 5 6 2 5 8 7 8 9 3 6 9,,,,,,, 2 6 10 6 10 14 10 14 18 #include void fun ( int a[3][3], int b[3][3]){ int c[3][3] ; int i, j ; for(i = 0 ; i < 3 ; i++) for(j = 0 ; j < 3 ; j++) { c[i][j] = a[j][i] ; /* ,,,,,?,, */ b[i][j] = a[i][j] + c[i][j] ; } } main( ) /* ,,,,, */ { int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, t[3][3] ; int i, j ; fun(a, t) ; for (i = 0 ; i < 3 ; i++) { for (j = 0 ; j < 3 ; j++) printf("%7d", t[i][j]) ; printf("\n") ; } NONO () ; } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,,fun,,,,,,,,,?,,,,,?,,,*/ int i, j, k, a[3][3], t[3][3] ; FILE *rf, *wf ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(k = 0 ; k < 5 ; k++) { for(i = 0 ; i < 3 ; i++) fscanf(rf, "%d %d %d", &a[i][0], &a[i][1], &a[i][2]) ; fun(a, t) ; for(i = 0 ; i < 3 ; i++) { for(j = 0 ; j < 3 ; j++) fprintf(wf, "%7d", t[i][j]) ; fprintf(wf, "\n") ; } } fclose(rf) ; fclose(wf) ; } 82.,,?,?,,,?,,,,,N,,,,,,,,,,,,,,,,,,з,,,,,,,,,,s,У,,,,д,,,,fun,,,?????,,,,,,,,,,,,?,,,,,,,,?,?,,,,,,,,,,? #include #define N 16 typedef struct { char num[10]; int s; } STREC; int fun( STREC a[] ) { STREC tmp; int i,j; for(i = 0; i < N; i++) for(j = i+1; j < N; j++) if(a[i].s < a[j].s) { tmp = a[i]; a[i] = a[j]; a[j] = tmp; } } main() { STREC s[N]={{"GA005",85},{"GA003",76},{"GA002",69},{"GA004",85}, {"GA001",91},{"GA007",72},{"GA008",64},{"GA006",87}, {"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91}, {"GA011",66},{"GA017",64},{"GA018",64},{"GA016",72}}; int i;FILE *out ; fun( s ); printf("The data after sorted :\n"); for(i=0;i void fun(int a, int b, long *c) { *c=(b/10)*1000+(a/10)*100+(b%10)*10+(a%10);} main() /* ,,,, */ { int a,b; long c; printf("Input a, b:"); scanf("%d%d", &a, &b); fun(a, b, &c); printf("The result is: %ld\n", c); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, a,b ; long c ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d,%d", &a, &b) ; fun(a, b, &c) ; fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ; } fclose(rf) ; fclose(wf) ; } 84.,,,д,,,,fun,,,,,,,,,,,,,,,, S=1+,,1+,,,2,,+,,1+,,,2+,,,3,,+,,+,,1+,,,2+,,,3+,,+,,,n,, ,,,,,,,,,,磺д,,,,,n,,,,20,,,,,?,, s=534.188884,, ?,,,,n,?,?,,,,1,,,,,,,,100,, #include #include double fun(int n) { int i; double fac=1.0; double sum=1.0; for(i=2;i<=n;i++) { fac+=sqrt(i); sum+=fac; } return sum; } main() { int n; double s; printf("\n\nInput n: "); scanf("%d",&n); s=fun(n); printf("\n\ns=%f\n\n",s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int n, i ; double s ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d", &n) ; s = fun(n) ; fprintf(wf, "%lf\n", s) ; } fclose(rf) ; fclose(wf) ; } 85.,,,,fun,?,,,,,,,,},,}λ,,,,,,,,,a,,b,,,,γ,?,,,,,,,,,c,С,,,,,?,,,,,,,a,,,,λ,,,λ ,,,4η,,,c,,,,λ,,,λ,,,b,,,,λ,,,λ,,,4η,,,c,,?,λ,,,λ,,,,,,,,磬a=45 b=12,,,,,,øú,,,, c=4152,, #include void fun(int a, int b, long *c) { *c=(a/10)*1000+(b/10)*100+(a%10)*10+(b%10);} main() { int a,b; long c; printf("Input a, b:"); scanf("%d,%d", &a, &b); fun(a, b, &c); printf("The result is: %d\n", c); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, a,b ; long c ; rf = fopen("C:\\WEXAM\\24990001\\in.dat", "r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d,%d", &a, &b) ; fun(a, b, &c) ; fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ; } fclose(rf) ; fclose(wf) ; } 86.,,,д,,,,fun,,,,,,,,,,,,,,,,3,,n,,,,,3,,n,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,磬д,,,,,n,,,,100,,,,,?,,sum=148.874270,,?,,,,n,?,?,,,,2,,,,,,,,100,, #include #include double fun(int n) { int i,j=0; double s=0; for (i=3; i<=n; i++) { for (j=2; j double fun(int n) { double s=0, t=1; int i ; for(i=1; i<=n; i++) { t *= i; s += 1./t; } return s; } main() { int n; double s; printf("\nInput n: "); scanf("%d",&n); s=fun(n); printf("\n\ns=%f\n\n",s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int n, i ; double s ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d", &n) ; s = fun(n) ; fprintf(wf, "%lf\n", s) ; } fclose(rf) ; fclose(wf) ; } 88.,,?,?,,,?,,,,,N,,,,,,,,,,,,,,,,,з,,,,,,,,,,s,У,,,,д,,,,fun,,,,?,,,,,,,,,?????? ,,,,,?,,,,,?,,,,b,,?,,,,,,,У,,,,,,,,?,,,,,,,,,,,β,n,,,??,,,,,,,,,,?,,,?,#include #define N 8 typedef struct { char num[10]; double s; } STREC; double fun( STREC *a, STREC *b, int *n ){ int i ; double ave = 0.0 ; *n = 0 ; for(i = 0 ; i < N ; i++) ave = ave + a[i].s ; ave /= N ; /* ,,,,,,,? */ for(i = 0 ; i < N ; i++) if(a[i].s < ave) { /* ,,,,,,?,?,?,?,,?,b,,?,,,,,,,, */ b[*n]=a[i] ; (*n)++; /* ,,,,,1 */ } return ave ; /* ,,,,,,,? */ } main() { STREC s[N]={{"GA05",85},{"GA03",76},{"GA02",69},{"GA04",85}, {"GA01",91},{"GA07",72},{"GA08",64},{"GA06",87}}; STREC h[N],t;FILE *out ; int i,j,n; double ave; ave=fun( s,h,&n ); printf("The %d student data which is lower than %7.3f:\n",n,ave); for(i=0;ih[j].s) {t=h[i] ;h[i]=h[j]; h[j]=t;} for(i=0;i #include int fun(char s[],char c) { char *p = s ; int i = 0 ; while(*p) { if(*p != c) s[i++] = *p ; p++ ; } s[i] = 0 ; } main() { static char str[]="turbo c and borland c++"; char ch; printf(",,,?,:%s\n", str); printf(",,,,?,,,?,:"); scanf("%c",&ch); fun(str,ch); printf("str[]=%s\n",str); NONO(); } NONO() { /* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,, ,,,,,?,,,,,?,,, */ FILE *rf, *wf ; char s[81], ch, w ; int len ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; fgets(s, 80, rf) ; fscanf(rf, "%c", &ch) ; len = strlen(s) - 1 ; w = s[len] ; if(w == '\n' || w == 0x1a) s[len] = 0 ; fun(s, ch) ; fprintf(wf, "%s", s) ; fclose(rf) ; fclose(wf) ; } 90.,,,д,,,,fun,,,,,,,:,,,,,,,,,,ж,,,,,,?,,Sn=1-1/2+1/3-1/4+,,+1/(2n-1)-1/2n ,,,,,,,,,,磬д,,,,,,,n,,,,8,,,,,?,,s=0.662872,,#include double fun(int n) { int i; double sum=0.0; if (n>1 && n<=100) { for(i=1; i<=n; i++) sum+=1.0/(2*i-1)-1.0/(2*i); } return sum; } main() { int n; double s; printf("\nInput n: "); scanf("%d",&n); s=fun(n); printf("\ns=%f\n",s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int n, i ; double s ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d", &n) ; s = fun(n) ; fprintf(wf, "%lf\n", s) ; } fclose(rf) ; fclose(wf) ; } 91.,,,д,,,,fun,,,,,,,,,,,,,,,,,,,,,,,,,?9,,,,ÿ,,,,},,,,,,,,,?,,,,,,,,,,, ,,,,,,,,,,磬е,9,,,,,,4,?12.0 34.0 4.0 23.0 34.0 45.0 18.0 3.0 11.0 ,,,,,?,,s=35.951014,,? #include #include double fun(double x[9]) { int i ; double avg=0.0,sum=0.0; for (i=0;i<8;i++) { avg=(x[i]+x[i+1])/2; sum+=sqrt(avg); } return sum; } main() { double s,a[9]={12.0,34.0,4.0,23.0,34.0,45.0,18.0,3.0,11.0}; int i; printf("\nThe original data is :\n"); for(i=0;i<9;i++)printf("%6.1f",a[i]); printf("\n\n"); s=fun(a); printf("s=%f\n\n",s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, j ; double s, a[9] ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 5 ; i++) { for(j = 0 ; j < 9 ; j++) fscanf(rf, "%lf", &a[j]) ; s = fun(a) ; fprintf(wf, "%lf\n", s) ; } fclose(rf) ; fclose(wf) ; } 92.,,,д,,,,,,,,,,,,,,,,,,,10,,,,?,,, S=,,?,1/10*,,,(Xk-x)2,,,,10,,,,,,,,?,, ,,,,x,,=1/10*,,,,Xk,, ,,,,,,磬10,,,,?95.0 89.0 76.0 65.0 88.0 72.0 85.0 81.0 90.0 56.0 ,,,?s=11.730729,, #include #include double fun(double x[10]) { int i; double avg=0.0, sum=0.0, abs=0.0, fc; for (i=0;i<10;i++) sum+=x[i]; avg=sum/10; /* ,,,,,,,? */ for (i=0;i<10;i++) abs+=(x[i]-avg)*(x[i]-avg); fc=sqrt(abs/10) ; return fc; } main() { double s, x[10]={95.0,89.0,76.0,65.0,88.0,72.0,85.0,81.0,90.0,56.0}; int i; printf("\nThe original data is :\n"); for(i=0;i<10;i++)printf("%6.1f",x[i]); printf("\n\n"); s=fun(x); printf("s=%f\n\n",s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int i, j ; double s, x[10] ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 5 ; i++) { for(j = 0 ; j < 10 ; j++) fscanf(rf, "%lf", &x[j]) ; s = fun(x) ; fprintf(wf, "%lf\n", s) ; } fclose(rf) ; fclose(wf) ; } 93.,,,д,,,,fun,,,,,,,,,,,,},,,?,?,,,,,,,õ,,,C,,,,,,,,,,,?,,,?,,,,,, ,,,,,,?,,,},,,?,,,,,,,,,,?,?,,,?, ,,,,,,,磬beijing shanghai ,,,,,shanghai,, #include char *fun ( char *s, char *t) { int i; char *p=s, *q=t; for(i=0;*p && *q; i++) { p++; q++; } if(*p == 0 && *q == 0) return s ; if(*p) return s ; else return t ; } main( ) { char a[20],b[20]; printf("Input 1th string:") ; gets( a); printf("Input 2th string:") ; gets( b); printf("%s\n",fun (a, b )); NONO (); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i ; char a[20], b[20] ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%s %s", a, b) ; fprintf(wf, "%s\n", fun(a, b)) ; } fclose(fp) ; fclose(wf) ; } 94.,,,д,,,,fun,,,,,,,,,,,,,,,,,,,ж,,,,,,?,,Sn=1+1/1!+1/2!+1/3!+1/4!+,,.+1/n! ,,,,,,,,,,磬д,,,,,n,,,,15,,,,,,,?,,s=2.718282,,#include double fun(int n) { double s=1 ; long t=1; int i; for(i=1; i<=n; i++) { t=t*i; /* ,,,,?, */ s+=1./t; /* ,,,,ÿ,,,?,,,,,,q,s,, */? } return s; /* ,,,?,,,,,,? */} main() { int n; double s; printf("Input n: "); scanf("%d",&n); s=fun(n); printf("s=%f\n",s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,,,,, fun ,,,,,,,,,?,,,,,?,,, */ FILE *rf, *wf ; int n, i ; double s ; rf = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(rf, "%d", &n) ; s = fun(n) ; fprintf(wf, "%lf\n", s) ; } fclose(rf) ; fclose(wf) ; } 95.,,,,,,,,,?,,,?,,,,?,,*,š,,,,д,,,,fun,,,,,,,,,,,,,,?,,,,,,β,,,,*,,,,,,,,,,,,,,,*,,,,,,,,β,h,?,?,,,?,,е,?,,,,?,,,β,b,,?,,,?,,,,,,? ,,,,?,,,,,д,,,,,,,,,,,,,,C,,,,,,,,,?,,,,,,磬,?,,е,,,,,?,,****A*BC*DEF*G******,,,,,?,?,,е,,,,,?,,****ABCDEFG******,,, ,,д,,,,,,,,,,,,,,C,,,,,,,,,?,,,#include void fun( char *a, char *h,char *p ){ int j=0; char *q=a; while(*q && q < h) a[j++] = *q++ ; while(*h && *p && h < p) { if(*h != '*') a[j++] = *h ; h++; } while(*p) a[j++] = *p++ ; a[j] = 0 ; } main() { char s[81],*t, *f; printf("Enter a string:\n");gets(s); t=f=s; while(*t)t++; t--; while(*t=='*')t--; while(*f=='*')f++; fun( s , f,t ); printf("The string after deleted:\n");puts(s); NONO(); } NONO() {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *in, *out ; int i ; char s[81], *t, *f ; in = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; out = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(in, "%s", s) ; t=f=s; while(*t)t++; t--; while(*t=='*')t--; while(*f=='*')f++; fun(s, f, t); fprintf(out, "%s\n", s) ; } fclose(in) ; fclose(out) ; } 96.,,,д,,,,fun,,,,,,,?,,, s=,,?,ln(1)+ln(2)+ln(3)+,,+ln(m),,s,,?,,,,?,,,?, ,,C,,,,,п,,,log(n),,,,,,ln(n),,log,,,,,,,,,,,,,,,double log(double x),,? ,,,,,磬m,,??,,20,,fun,,,,??,,6.506583,,#include #include double fun( int m ) { double s = 0.0 ; int i ; for(i = 1 ; i <= m ; i++) s += log(1.0 * i) ; s = sqrt(s) ; return s ; } main() { printf("%f\n", fun(20)); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, n ; double s ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%d", &n) ; s = fun(n) ; fprintf(wf, "%f\n", s) ; } fclose(fp) ; fclose(wf) ; } 97.,,?,?,,,?,,,,,N,,,,,,,,,,,,,,,,,,з,,,,,,,,,,s,У,,,,д,,,,fun,,,?????,,,,,,,,,,,?,,,?,,,,,??,,?,,,,,,,,,,,,,,,,,??,,û,?,?,,,,,,?,,?,,,,,,и,,,,ÿ,,,,,,,,,-1,,,,?,,,???,?,,,?,,,,,,,,?,,?,,,,,strcmp,,,,?#include #include #define N 16 typedef struct { char num[10]; int s; } STREC; STREC fun( STREC *a, char *b ){ STREC c ; int i ; c.num[0] = '\0' ; /* ,ó,,,,, */ c.s = -1 ; /* ,ó,?-1 */? for(i = 0 ; i < N ; i++) if(strcmp(a[i].num, b)==0) { /* ,ж,,,,,,,,, */? strcpy(c.num, a[i].num) ; /* ,,,,,,,,?,,и?,? */ c.s=a[i].s; /* ,,,,,,,,,,,и?,? */ break ; /* ,,,,,,, */? } return c ; /* ,,,,,,,, */? } main() { STREC s[N]={{"GA005",85},{"GA003",76},{"GA002",69},{"GA004",85}, {"GA001",91},{"GA007",72},{"GA008",64},{"GA006",87}, {"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91}, {"GA011",77},{"GA017",64},{"GA018",64},{"GA016",72}}; STREC h; char m[10]; int i;FILE *out ; printf("The original data:\n"); for(i=0; i #include void fun ( char *ss ) { int i ; for(i = 1 ; i < strlen(*ss) ; i+=2) { if(ss[i] >= 'a' && ss[i] <= 'z') ss[i] -= 32 ; } } main( ) { char tt[81] ; printf( "\nPlease enter an string within 80 characters:\n" ); gets( tt ); printf( "\n\nAfter changing, the string\n \"%s\"", tt ); fun( tt ); printf( "\nbecomes\n \"%s\"\n", tt ); NONO ( ); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; char tt[81] ; int i ; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%s", tt) ; fun( tt ) ; fprintf(wf, "%s\n", tt) ; } fclose(fp) ; fclose(wf) ; } 99.,,?,?,,,?,,,,,N,,,,,,,,,,,,,,,,,,з,,,,,,,,,,s,У,,,,д,,,,fun,,,?????,,,,,,,,,,,,?,,,,,,?,,,,b,,?,,,,,,,У,?,,,,,,,,,,,,,?,,,??,,,,,,,,,,,?,,,,,,,?#include #define N 16 typedef struct { char num[10]; int s; } STREC; int fun( STREC *a, STREC *b ) { int i, max = a[0].s, n=0; for(i = 1; i < N; i++) if(max < a[i].s) max = a[i].s ; /* ,?,,,,, */? for(i = 0; i < N; i++) if(max==a[i].s) b[n++] = a[i] ; /* ,,,,,,,,,,,,,,,,,,,,b,, */? return n; /* ,,,?,,,,,,,,,, */ } main() { STREC s[N]={{"GA05",85},{"GA03",76},{"GA02",69},{"GA04",85}, {"GA01",91},{"GA07",72},{"GA08",64},{"GA06",87}, {"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91}, {"GA011",77},{"GA017",64},{"GA018",64},{"GA016",72}}; STREC h[N]; int i,n;FILE *out ; n=fun( s,h ); printf("The %d highest score :\n",n); for(i=0;i float fun(int n) { int i,j,t; float s=0; for(i=1;i<=n;i++) { t=0; for(j=1;j<=i;j++) t+=j; s=s+1./t; } return s; } main() { int n; float s; printf("\nPlease enter N:"); scanf("%d", &n); s = fun(n); printf("the result is: %f\n", s); NONO(); } NONO ( ) {/* ,,,,,,,,,,,,?,,,,,,,,,,,,,,ú,,,,,,,,?,,,,,?,,, */ FILE *fp, *wf ; int i, n ; float s; fp = fopen("C:\\WEXAM\\24990001\\in.dat","r") ; wf = fopen("C:\\WEXAM\\24990001\\out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%d", &n) ; s = fun(n) ; fprintf(wf, "%f\n", s) ; } fclose(fp) ; fclose(wf) ;}
本文档为【c语言二级考试编程题库】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_003124
暂无简介~
格式:doc
大小:300KB
软件:Word
页数:162
分类:企业经营
上传时间:2018-01-11
浏览量:36