运行以下程序,输入5个数字,分别是1 3 5 7 9,写出程序的运行结果。#includeint main(void){const int n=5;int i;double average, sum;int a[n];printf("Enter %d integers: ",n);sum = 0;for(i =0; iaverage:");for(i = 0; i average)printf("%d ", a[i]);}printf("\n");return 0;}
查看答案
运行以下程序,输入zoo,写出程序的运行结果。# include # include # define MAXLINE 100void encrypt ( char *s);int main (void){char line [MAXLINE];printf ("Input the string: ");gets(line);encrypt (line);printf ("%s\n", line);return 0;}void encrypt ( char *s){for ( ; *s != '\0'; s++)if (*s == 'z')*s = 'a';else*s = *s+1;}
运行以下程序,输入15 8 7 6 12,写出程序运行结果。#include void fun(int a[ ], int n);int main(void){int n, a[5];int i;for (i=0; i<5;i++)scanf("%d",&a[i]);fun(a,5);for (i=0; i<4; i++)printf("%d#",a[i]);printf("%d",a[4]);return 0;}void fun(int a[ ], int n){int i, j, t;for( i = 1; i < n; i++ )for (j = 0; j < n-i; j++ )if (a[j] > a[j+1]){t=a[j]; a[j]=a[j+1]; a[j+1]=t;}}
运行以下程序,输入21252,写出程序运行结果。#include int fun(int number, int digit);int main(void){int count, in;scanf("%d", &in);count = fun(in, 2);printf("%d#%d\n", in, count);return 0;}int fun(int number, int digit){int count;if(number < 0) number = -number;count = 0;do{if(number % 10 == digit) count++;number = number / 10;}while(number != 0);return count;}
运行以下程序,输入2 10,写出程序运行结果。#include #include int fun(int m);int main(){int count, i, m, n, sum;int prime(int m);scanf("%d%d", &m, &n);count = sum = 0;for(i = m; i <= n; i++)if(fun(i) != 0){count++;sum = sum + i;}printf("%d#%d\n", count, sum);}int fun(int m){int k, i;if(m == 1) return 0;k = sqrt(m);for(i = 2; i <= k; i++)if(m % i == 0) return 0;return 1;}