天天动画片 > 八卦谈 > 期末复习资料C 语言大题

期末复习资料C 语言大题

八卦谈 佚名 2023-07-07 03:11:21


第1题操作题

/*求菲玻那契数列的前20项。菲玻那契数列前2项分别是1,1,从第3项开始,各项分别是其前2项之和。*/

#include <stdio.h>

void fibonacci(int f[])

{ int i;

/************Fill in the blanks************/

  for(i=2;i<20;i++)

/************Fill in the blanks************/

    f[i]=f[i-1]+f[i-2];

}

main()

{ int f[20]={1,1},i;

  fibonacci(f);

  printf("\n菲玻那契数列的前20项为: ");

  for(i=0;i<20;i++){

    if(i%5==0) printf("\n");

/************Fill in the blanks************/

    printf("%12d",f[i]);

    }

 getch();

}

第2题操作题

/*将一个二维数组a的行和列元素互换,存到另一个二维数组b中。*/

#include <stdio.h>

void trans(int a[2][3],int b[3][2])

{/* 本函数将二维数组a的行和列元素互换,存到二维数组b中 */

/**********Error**********/

  int i,j;

  for(i=0;i<2;i++)

    for(j=0;j<3;j++)

/**********Error**********/

      b[j][i]=a[i][j];

}

main()

{ int a[2][3]={{1,2,3},{4,5,6}},b[3][2],i,j;

  printf("数组a:\n");

  for(i=0;i<2;i++){

    for(j=0;j<3;j++)

      printf("%5d",a[i][j]);

    printf("\n");

  }

  trans(a,b);

  printf("数组b:\n");

  for(i=0;i<3;i++){

    for(j=0;j<2;j++)

      printf("%5d",b[i][j]);

    printf("\n");

  }

  getch();

}

第3题操作题

/*找出数组arr[]中的最大元素。

suffix函数的功能是:求出形参数组a[]中最大元素的下标。其中,形参n为数组元素的个数。

例如, 数组元素为: 56 178 6 123 87 243 161 124 78 143

则输出结果为:

数组arr的最大元素为: arr[5]=243 */

 

#include <stdio.h>

 

int suffix(int a[],int n)

{ int i,k,max;

max=a[0];

for(i=1;i<n;i++)

if(max<a[i]){max=a[i];k=i;}

return k;

}

 

main()

{ void CHECK();

  int arr[10]={56,178,6,123,87,243,161,124,78,143},k;

  clrscr();

  k=suffix(arr,10);

  printf("数组arr的最大元素为: arr[%d]=%d\n",k,arr[k]) ;

  getch();

  CHECK();

}

第4题操作题

/*在sum函数中,根据整型形参m,计算如下公式的值。

            1         1           1                 1

    y = ------- + --------- + --------- + …… + -------

        100*100    200*200     300*300             m*m

    例如,若形参 m = 2000,则程序输出:

The result is: 0.000160。*/

 

#include <stdio.h>

/************Fill in the blanks************/

double sum(int m)

{ int i;

  double y,d;

/************Fill in the blanks************/

  y=0;

  for(i=100;i<=m;i+=100){

    d = (double)i * (double)i ;

    y += 1.0/d;

    }

/************Fill in the blanks************/

  return(y);

}

 

main( )

{ int n = 2000 ;

  printf("\nThe result is: %lf\n",sum(n));

  getch();

}

第5题操作题

/*比较数组a[]和数组b[]中,a[i]>b[i]、a[i]=b[i]和a[i]<b[i]的次数。

其中comp函数的功能是:当x>y时,返回1;当x=y时,返回0;当x=y时,返回0。*/

#include <stdio.h>

/**********Error**********/

int comp(int x,int y)

{ int flag;

  if(x>y) flag=1;

/**********Error**********/

  else if(x==y) flag=0;

  else flag=-1;

  return(flag);

}

main()

{ int i,n=0,m=0,k=0;

  int a[10]={5,-23,5,21,6,18,9,12,23,7};

  int b[10]={6,-9,64,23,-52,0,9,8,-35,12};

  printf("数组a:\n");

  for(i=0;i<10;i++) printf("%4d",a[i]);

  printf("\n");

  printf("数组b:\n");

  for(i=0;i<10;i++) printf("%4d",b[i]);

  printf("\n");

 for(i=0;i<10;i++){

    if(comp(a[i],b[i])==1) n=n+1;

    else if(comp(a[i],b[i])==0) m=m+1;

    else k=k+1;

    }

  printf("a[i]>b[i]%2d 次\na[i]=b[i]%2d 次\na[i]<b[i]%2d 次\n",n,m,k);

  getch();

}

第6题操作题

/*将 1 到 n 之间,能同时被 7 和 11 整除的整数存储到形参数组a[]中,并返回这些整数的个数。

例如:当 n = 1000 时,程序输出:77 154 231 308 385 462 539 616 693 770 847 924 */

 

#include <stdio.h>

 

int fun(int a[],int n)

{ int i;  int k=0;

  for(i=1;i<=n;i++)

  if(i%7==0&&i%11==0)

  {a[k]=i;

   k++;

   }

   return k;

}

 

main()

{ void CHECK();

  int arr[20],i,k,n;

  clrscr();

  n=1000;

  k=fun(arr,n);

  for(i=0;i<k;i++)

    printf("%4d",arr[i]);

    getch();

  CHECK();

}

第7题操作题

/*计算N×N的二维数组的所有数组元素的平均值。

    例如:a 数组中的值为

                |0  1  2  7  9|

                |1  9  7  4  5|

           a =  |2  3  8  3  1|

                |4  5  6  8  2|

                |5  9  1  4  1|

则平均值为: 4.280000。*/

 

#include <stdio.h>

#define N  5

 

float count(int a[N][N])

{ int i,j;

float sum=0,ave;

for(i=0;i<N;i++)

for(j=0;j<N;j++)

sum=sum+a[i][j];

ave=sum/(N*N);

return ave;

}

 

main()

{ void CHECK();

  int arr[N][N]={{0,1,2,7,9},{1,9,7,4,5},{2,3,8,3,1},{4,5,6,8,2},{5,9,1,4,1}};

  clrscr();

  printf("二维数组arr的元素的平均值为:%f\n",count(arr)) ;

  getch();

  CHECK();

}

第8题操作题

/*求广义菲玻那契数列的第n项。广义菲玻那契数列前3项分别是1,1,1,从第4项开始,各项分别是其前3项之和。广义菲玻那契级数的前n项为:1,1,1,3,5,9,17,31,…… 。

例如,若 n = 20,则应输出

广义菲玻那契级数的第20项为: 46499。*/

 

#include <stdio.h>

long fibonacci(int n)

{ long a=1,b=1,c=1,d;

  int i;

/************Fill in the blanks************/

  for(i=4;i<=n;i++)

    {

/************Fill in the blanks************/

    d=a+b+c;

    a=b;

    b=c;

    c=d;

    }

/************Fill in the blanks************/

  return d;

}

 

main()

{ int n=20;

  printf("广义菲玻那契级数的第%d项为: %ld\n",n,fibonacci(n));

  getch();

}

第9题操作题

/*应用冒泡排序算法,对数组a[]中的元素从小到大进行排序。*/

#include <stdio.h>

void sort(int a[],int n)

{ int i,j,t;

  for(j=0;j<n-1;j++)

    for(i=0;i<n-1-j;i++)

      if(a[i]>a[i+1]){

        t=a[i];

/**********Error**********/

        a[i]=a[i+1];

/**********Error**********/

        a[i+1]=t;

      }

}

main()

{ int k,a[10]={6,-9,78,23,-12,0,9,8,-3,12};

  printf("数组a:\n");

  for(k=0;k<10;k++)

    printf("%d ",a[k]);

  sort(a,10);

  printf("\n从小到大排序:\n");

  for(k=0;k<10;k++)

    printf("%d ",a[k]);

  printf("\n");

  getch();

}

第10题操作题

/*计算1到形参n之间,能被3和7整除的整数的和,并作为函数值返回。

例如,n为1800时,程序输出:

1到1800之间,能被3和7整除的整数的和为: 76755 */

 

#include <stdio.h>

 

long sum(int n)

{

 int i;

 long sum=0;

 for(i=1;i<=n;i++)

 if(i%3==0&&i%7==0)

 sum=sum+i;

 return(sum);

}

 

main()

{ void CHECK();

  int n=1800;

  clrscr();

  printf("1到%d之间,能被3和7整除的整数的和为: %ld\n",n,sum(n)) ;

  getch();

  CHECK();

}

第11题操作题

/*统计子字符串substr在字符串str中出现的次数。

例如,若字符串为This is a C Program,子字符串为is,则应输出2。*/

 

#include <stdio.h>

 

int count(char str[],char substr[])

{ int i,j,k,num=0;

/************Fill in the blanks************/

  for(i=0;str[i]!='\0';i++)

    for(j=i,k=0;substr[k]==str[j];k++,j++)

/************Fill in the blanks************/

      if(substr[k+1]=='\0')

    {

    num++;

    break;

    }

/************Fill in the blanks************/

  return num;

}

 

main()

{

  char str[80],substr[80];

  printf("Input a string: ");

  gets(str);

  printf("Input a substring: ");

  gets(substr);

  printf("The result is: %d\n",count(str,substr));

  getch();

}

第12题操作题

/*求二维数组a[3][3]中各列元素的平均值,并依次存储在一维数组b[3]中。*/

#include <stdio.h>

void  fun(int a[3][3],float b[3])

{  int i,j;

   for(i=0;i<3;i++){

     for(j=0;j<3;j++)

/**********Error**********/

       b[j]+=a[i][j];

     }

   for(i=0;i<3;i++)

/**********Error**********/

     b[i]/=3;

}

main()

{ int a[3][3]={{1,2,3},{4,5,6},{7,8,9}},i;

  float b[3]={0,0,0};

  fun(a,b);

  for(i=0;i<3;i++)

    printf("%4.1f ",b[i]);

  printf("\n") ;

  getch();

}

第13题操作题

/*有一个3×4的矩阵,求所有元素中的最小值。*/

#include <stdio.h>

min_value(int array[][4])

{ int i,j,min;

  min=array[0][0];

  for(i=0;i<3;i++)

/************Fill in the blanks************/

    for(j=0;j<4;j++)

      if(array[i][j]<min)

/************Fill in the blanks************/

        min=array[i][j];

/************Fill in the blanks************/

  return(min);

}

main()

{ int a[3][4]={{-11,23,15,37},{29,48,6,-8},{15,17,34,12}};

  printf("矩阵中所有元素的最小值= %d\n",min_value(a));

  getch();

}

第14题操作题

/*求班级学生考试成绩的平均值。*/

#include <stdio.h>

float average(float array[],int n)

{ int i;

  float aver,sum=array[0];

/************Fill in the blanks************/

  for(i=1;i<n;i++)

    sum=sum+array[i];

/************Fill in the blanks************/

  aver=sum/n;

/************Fill in the blanks************/

  return (aver);

}

main()

{ float score_1[5]={98.5,97,91.5,60,55};

  float score_2[10]={67.5,89.5,99,69.5,77,89.5,76.5,54,60,99.5};

  printf("班级A学生考试成绩的平均值= %6.2f\n",average(score_1,5));

  printf("班级A学生考试成绩的平均值= %6.2f\n",average(score_2,10));

  getch();

}

第15题操作题

/*将每个英语单词的第一个字母改成大写(这里的“单词”是指由空格隔开的字符串)。

例如,若输入:I am a student to take the examination.,

则应输出:I Am A Student To Take The Examination.。*/

 

#include  <stdio.h>

/**********Error**********/

void change(char s[])

{ int i,k;

  k=0;

/**********Error**********/

  for(i=0;s[i]!='\0';i++)

    if(k)

      {if(s[i]==' ') k=0;}

    else if(s[i]!=' ')

      {k=1;

      s[i]=toupper(s[i]);

      }

}

 

main()

{ char str[80];

  printf("\nPlease enter an English text line: ");

  gets(str);

  printf( "Before changing:\n  %s",str);

  change(str);

  printf("\nAfter changing:\n  %s\n",str);

  getch();

}

第16题操作题

/*计算

       1     1     1     1         1

  1 - --- + --- - --- + --- - ... ---

       2     3     4     5         n

 

例如,n=100时,运算结果为:0.688172。*/

 

#include <stdio.h>

 

float count(int n)

{ int i;

float sign=1; float sum=0;

for(i=1;i<=n;i++)

{

sum=sum+sign/i;

sign=(-1)*sign;

}

return sum;

}

 

main()

{ void CHECK();

  int n=100;

  clrscr();

  printf("     1     1     1     1         1\n");

  printf("1 - --- + --- - --- + --- - ... --- = %f\n",count(n));

  printf("     2     3     4     5        %d\n",n);

  getch();

  CHECK();

}

第17题操作题

/*求出以下分数序列的前n项之和。

       2      3      5      8     13     21

     ┄┄ , ┄┄ , ┄┄ , ┄┄ , ┄┄ , ┄┄ , ……

       1      2      3      5     8      13

    例如,若n = 5,则应输出:8.391667。*/

 

#include <stdio.h>

/************Fill in the blanks************/

double sum(int n)

{ int a,b,c,k;

  double s;

/************Fill in the blanks************/

  s=0;

  a=2;

  b=1;

  for(k=1;k<=n;k++){

    s=s+(double)a/b;

    c=a;

/************Fill in the blanks************/

    a=b+c;

    b=c;

    }

  return s;

}

 

main()

{ int n=5;

  printf("\nThe value of function sum is: %lf\n",sum(n));

  getch();

}

第18题操作题

/*计算两个双精度数的和的平方根。

例如,若输入:23.18,32.4721,则输出:z=7.460034。*/

#include <math.h>

/**********Error**********/

double count(double a,double b)

{ double c;

/**********Error**********/

  c=sqrt(a+b);

  return c;

}

main()

{ double x,y,z;

  printf("Enter x,y:");

  scanf("%lf,%lf",&x,&y);

  z=count(x,y);

  printf ("z=%f\n",z);

  getch();

}

第19题操作题

/*计算n!。例如,给n输入5,则输出5!=120。*/

#include <stdio.h>

long count(int n)

{ int i;

long s=1;

for(i=1;i<=n;i++)

s=s*i;

return s;

}

 

main()

{ void CHECK();

  int n;

  clrscr();

  printf("Input N:");

  scanf("%d", &n);

  printf("%d! =% ld\n",n,count(n));

  getch();

  CHECK();

}

 

第20题操作题

/*输出M行M列整数方阵,并计算主对角线上各元素之和。*/

#include <stdio.h>

#define  M  5

/************Fill in the blanks************/

int count(int n,int a[M][M])

{ int i,sum=0;

  for(i=0;i<n;i++)

    sum += a[i][i];

/************Fill in the blanks************/

  return(sum);

}

 

main( )

{ int arr[M][M]={{1,2,3,4,5},{4,3,2,1,0},{6,7,8,9,0},{9,8,7,6,5},{3,4,5,6,7}};

  int i,j;

  printf("\n%d×%d 数组元素为:\n",M,M);

  for(i=0;i<M;i++ ){

    for(j=0;j<M;j++ )

/************Fill in the blanks************/

      printf("%4d",arr[i][j]);

    printf("\n");

    }

  printf ( "主对角线上各元素之和为: %d",count(M,arr));

  getch();

}

第21题操作题

/*将字符串s中的内容按逆序重新存储。

例如,若字符串s中的内容为abcd,则应将字符串s中的内容变为:dcba*/

 

#include <stdio.h>

 

void invert(char str[],int n)

{int i;char temp;

for(i=0;i<n/2;i++)

{temp=str[i];

str[i]=str[n-1-i];

str[n-1-i]=temp; }

}

 

main()

{ void CHECK();

  char s[10]="abcd";

  int n=4;

  clrscr();

  printf("处理前字符串=%s\n", s);

  invert(s,n);

  printf("处理后字符串=%s\n", s);

  getch();

  CHECK();

}

 

第22题操作题

/*输入一行字符,统计其中大写字母、小写字母、空格、数字及其它字符个数。*/

#include <stdio.h>

int upper,lower,digit,space,other;

/************Error************/

void count(char str[])

{ int i=0;

  while(str[i]!='\n')

  { if((str[i]>='A')&&(str[i]<='Z'))

      upper++;

    else if((str[i]>='a')&&(str[i]<='z'))

      lower++;

/************Error************/

    else if(str[i]==' ')

      space++;

    else if((str[i]>='0')&&(str[i]<='9'))

      digit++;

    else

      other++;

    i++;

  }

}

main()

{ int i=0;

  char s[80];

  printf("\n请输入一行字符:");

  while((s[i]=getchar())!='\n') i++;

  upper=lower=digit=space=other=0;

  count(s);

  printf("其中,大写字母个数:%d,小写字母个数:%d,空格个数:%d,数字个数:%d,其它字符个数:%d",upper,lower,space,digit,other);

getch();}

第23题操作题

/*输入一个字符串(不超过80个字符),按逆序存放。*/

#include <stdio.h>

/************Error************/

void inverse(char str[])

{ int i,j;

  char t;

  for(i=0,j=strlen(str);i<strlen(str)/2;i++,j--){

    t=str[i];

/************Error************/

    str[i]=str[j-1];

    str[j-1]=t;

    }

}

main()

{ char str[80];

  int i=0;

  printf("\n请输入一个字符串:");

  while((str[i]=getchar())!='\n') i++;

  str[i]='\0';

  inverse(str);

  printf("此字符串的逆序为:%s",str);

  getch();

}

第24题操作题

/*求出数组arr中的最大数,并把最大数和arr[0]中的数进行交换。*/

#include <stdio.h>

#define  N   20

/************Fill in the blanks************/

void swap(int a[],int n)

{ int k, m, t ;

  m=0;

/************Fill in the blanks************/

  for(k=0;k<n;k++)

    if(a[k]>a[m]) m=k;

  t=a[0];

/************Fill in the blanks************/

  a[0]=a[m];

  a[m]=t;

}

 

main( )

{ int i,n=10,arr[N]={0,5,12,10,23,6,9,7,10,8};

  printf("\n交换前:");

  for(i=0;i<n;i++) printf("%4d",arr[i]);

  swap(arr,n);

  printf("\n交换后:");

  for(i=0;i<n;i++) printf("%4d", arr[i]);

  printf("\n");

}

第25题操作题

/*计算正整数num的各位上的数字的乘积。

例如,若输入:2418,则输出应该是:64。若输入:106,则输出应该是:0。*/

 

#include <stdio.h>

 

long count(long num)

{int n;

long s=1;

while(num!=0)

{

n=num%10;

s=s*n;

num=num/10;

}

return s;

}

main()

{ void CHECK();

  long n ;

  clrscr();

  printf("\Please enter a number:");

  scanf("%ld",&n);

  printf("%ld\n",count(n));

  CHECK();

}

 

第26题操作题

/*统计形参s[]所指字符串中数字字符出现的次数。

例如,形参s[]所指的字符串为:sjk7gr7we98yv98y3。输出结果为:

字符串sjk7gr7we98yv98y3中数字字符出现的次数为: 7 */

 

#include <stdio.h>

#define N  80

 

int count(char s[])

{

    int i,k=0;

   for(i=0;s[i]!='\0';i++)

   if(s[i]>='0'&&s[i]<='9')

     k++;

 

   return k;

 

 

}

 

main()

{ void CHECK();

  char arr[N]="sjk7gr7we98yv98y3";

  clrscr();

  printf("字符串%s中数字字符出现的次数为: %d\n",arr,count(arr)) ;

  CHECK();

}

第27题操作题

/*将小写字母转换为大写字母。

例如:C Language,转换为C LANGUAGE。*/

 

#include <stdio.h>

 

void change(char s[])

{

   int i;

   for(i=0;s[i]!='\0';i++)

     if(s[i]>='a'&&s[i]<='z')

     s[i]=s[i]-32;

}

main()

{ void CHECK();

  char str[20]="C Language";

  clrscr();

  change(str);

  printf("%s\n",str);

  CHECK();

}

第28题操作题

/*求二维数组a[3][3]中各列元素的最大值,并依次存储在一维数组b[3]中。*/

#include <stdio.h>

void  fun(int a[3][3],int b[3])

{  int i,j;

   for(i=0;i<3;i++){

/**********Error**********/

     b[i]=a[0][i];

     for(j=1;j<3;j++)

       if(b[i]<a[j][i])

/**********Error**********/

     b[i]=a[j][i];

     }

}

main()

{ int a[3][3]={{11,-2,43},{-4,5,0},{17,68,19}},b[3],i;

  fun(a,b);

  for(i=0;i<3;i++)

    printf("%5d",b[i]);

  printf("\n") ;

}

第29题操作题

/*计算1!+2!+3!+...+n!。*/

#include <stdio.h>

long count(int n)

{ int i;

  long sum=0,p=1;

/************Fill in the blanks************/

  for(i=1;i<=n;i++)

    {

    p=p*i;

/************Fill in the blanks************/

    sum=sum+p;

    }

  return(sum);

}

 

main( )

{

  int n;

  printf("计算1!+2!+3!+...+n!\n请输入n的值(3<n<10):");

/************Fill in the blanks************/

  scanf("%d",&n);

  printf("1!+2!+...+%d!=%ld\n",n,count(n));

}

第30题操作题

/*判断字符c是否与字符串str中的某个字符相同;若相同,什么也不做,若不同,则将字符c添加在字符串str的尾部。*/

#include <stdio.h>

void insert(char *s,char c)

{

  while(*s && *s!=c) s++;

/**********Error**********/

    if(*s!=c)

    {

      *s=c;

/**********Error**********/

      *(s+1)='\0';

    }

}

main()

{

  char str[80], c;

  printf( "\n请输入一个字符串:");

  gets(str);

  printf("请输入一个字符:");

  c=getchar();

  insert(str, c) ;

  printf("操作结果为:%s\n",str);

}

 

 

1:编程实现:

sssssssssssss

I must work hard

sssssssssssss

 

# include<stdio.h>

main()

{printf(sssssssssssss\n);

printf(“I must work hard\n);

printf(sssssssssssss\n);

}

 

 

 

 

2:编程实现:

 *******

   *******

     *******

       *******

 

# include<stdio.h>

main()

{printf(*******\n);

printf( *******\n);

printf(  *******\n);

printf(   *******\n);

}

 

 

 

 

3:编程实现从键盘上输入一个百分制成绩:85-100分为优秀,75-85分为良,

60-75合格,小于60分不及各。

 

# include<stdio.h>

main()

{float x;printf(请输入一个百分制成绩\n);

scanf(%f,&x);

if(x>=85&&x<=100)printf(优秀\n);

else if(x>=75&&x<=85)printf(良\n);

else if(x>=60&&x<=75)printf(合格\n);

else printf(不及格\n);

}

4:用switch选择结构编程实现从键盘上输入百分制成绩score,然后把这个百分制score转换成相互五分制成绩,90<=score<=100,gread为A;80<=score<=90,gread为B;70<=score<=80gread为C;60<=gread<=70gread为D;score<60gread为E

 

# include<stdio.h>

main()

{int score;char gread;

  scanf(%d,&score);

  switch(score/10)

  {  case 10:

     case 9:{grade=A’;printf(“%c\n”,grade);}break;

     case 8:{grade=B’;printf(“%c\n”,grade);}break;

     case 7:{grade=C’;printf(“%c\n”,grade);}break;

     case 6:{grade=D’;printf(“%c\n”,grade);}break;

     default:printf {grade=A’;printf(“%c\n”,grade);}break;

   }

}

 

5:编程实现5!

# include<stdio.h>

main()

int t=1,i;

  for(i=1;i<=5;i++)

  t=t*i;

  printf(“%d\n”,t);

}

 

 

 

6:编程实现从键盘上输入一个正整数,然后判断这个正整数是否是素数。

 

# include<stdio.h>

main()

int i,t=2;

  scanf(“%d”,&i);

  while(t<i)

 {if(i%t==0)

  {printf(“不是素数\n”);break;

  }

   t++;

}

  if(t==i)printf(“是素数\n”);

}

 

 

7:编程实现打印所有水仙花数(水仙花数是指一个3位数,其各位数字立方和等于该数本身。)

  

# include<stdio.h>

main()

{int i,j,k,n;

 printf(the naricissus number is:\n”);

 for(n=100;n<1000;n++)

 {

i=n/100;

j=n/10-i*10;

k=n%10;

if(i*i*i+j*j*j+k*k*k==n)

printf(“%d\n”,n);

}

}

 

 

 

8:编程实现从键盘上输入10个数,并求出这10个数中最大值(要求:用数组编程实现。)

# include<stdio.h>

main()

int a[10],I,max;

 for(i=0;i<10;i++)

 scanf(“%d”,&a[i]);

 max=a[0];

 fof(i=0;i<10;i++)

 {if(max<a[i]) max[i];

 }

  Printf(“max=%d”,max);

}

 

 

 

9:编程实现5+10+15++100的和。

# include<stdio.h>

main()

int i,sum=0;

  for(i=5;i<=100;i+=5)

  sum+=i;

  printf(“sum=%d”,sum);

}

 

 

 

 

10:编程实现打印九九乘法表

# include<stdio.h>

main()

{int i,j;

 for(i=1;i<=9;i++)

 {

for(j=1;i<=i;j++)

printf(“%d*%d=%d\t”,j,i,i*j);

printf(“\n”);

}

}

 

 

 


本文标题:期末复习资料C 语言大题 - 八卦谈
本文地址:www.ttdhp.com/article/36195.html

天天动画片声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
扫码关注我们