亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      考試首頁 | 考試用書 | 培訓(xùn)課程 | 模擬考場 | 考試論壇  
      全國  |             |          |          |          |          |         
        當(dāng)前位置:計(jì)算機(jī)等級(jí) > 二級(jí)考試 > C語言程序設(shè)計(jì) > C語言模擬試題 > 文章內(nèi)容
        

      全國計(jì)算機(jī)二級(jí)考試C語言試題與答案精選第一套(程序設(shè)計(jì)題)

      中華IT學(xué)院   【 】  [ 2016年6月14日 ]

      程序設(shè)計(jì)

      /*------------------------------------------------

      【程序設(shè)計(jì)】

      --------------------------------------------------

       

      功能:計(jì)算并輸出給定整數(shù)n的所有因子之和(不包括1與

            自身)。

      注意:n的值不大于1000。

      例如:n的值為855時(shí),應(yīng)輸出704。

       

      ------------------------------------------------*/

       

      #include "stdio.h"

       

      int fun(int n)

      {

       

        /*********Begin**********/

       

       

       

       

       

       

        /**********  End  **********/

       

      }

      void TestFunc()

      {

        FILE *IN,*OUT;

        int iIN,iOUT,i;

        IN=fopen("in.dat","r");

        if(IN==NULL)

        {

          printf("Please Verify The Currernt Dir..It May Be Changed");

        }

        OUT=fopen("out.dat","w");

        if(OUT==NULL)

        {

          printf("Please Verify The Current Dir.. It May Be Changed");

        }

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

        {

          fscanf(IN,"%d",&iIN);

          iOUT=fun(iIN);

          fprintf(OUT,"%d\n",iOUT);

        }

        fclose(IN);

        fclose(OUT);

      }

      main()

      {

        printf("s=%d\n",fun(855));

        TestFunc();

      }

       

       

      【參考代碼】

       

      int s=0,i;

         for(i=2;i

          if(n%i==0)s=s+i;

           return s;

       

       

      /*------------------------------------------------------

      【程序設(shè)計(jì)】

      --------------------------------------------------------

      功能:刪去一維數(shù)組中所有重復(fù)的數(shù),只保留不同的數(shù)。

      數(shù)組中的數(shù)已按由小到大的順序排列,

      函數(shù)返回刪除后數(shù)組中數(shù)據(jù)的個(gè)數(shù)。

      例如:一維數(shù)組中的數(shù)據(jù)是: 2 2 2 3 4 4 5 6 6 6 6 7 7 8 9 9 10 10 10。

      刪除后,數(shù)組中的內(nèi)容應(yīng)該是: 2 3 4 5 6 7 8 9 10。

      注意:請勿改動(dòng)主函數(shù)main和其它函數(shù)中的任何內(nèi)容。

      ------------------------------------------------------*/

      #include "stdio.h"

      #define N 80

       

      int fun(int a[],int n)

      {

          /*********Begin**********/

        

       

       

       

          /**********  End  **********/

      }

       

      main()

      {

          void TestFunc();

          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

          for(i=0;i

          TestFunc();

      }

       

      void TestFunc()

      {

          FILE *IN,*OUT;

          int a[N];

          int n;

          int i;

          IN=fopen("in.dat","r");

          if(IN==NULL)

          {

              printf("Read File Error");

          }

          OUT=fopen("out.dat","w");

          if(OUT==NULL)

          {

              printf("Write File Error");

          }

          fscanf(IN,"%d",&n);

          for(i=0;i

          n=fun(a,n);

          for(i=0;i

      分享到:
      本文糾錯(cuò)】【告訴好友】【打印此文】【返回頂部
      將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動(dòng)訪問考試網(wǎng) | 復(fù)制本頁地址,傳給QQ/MSN上的好友 | 申請鏈接 | 意見留言 TOP
      關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導(dǎo)航  考試論壇
      Copyright © 2006-2017 中華考試網(wǎng)(Examw.com) All Rights Reserved  營業(yè)執(zhí)照