家们网!                                                   鼎誉推广助手 长沙网站制作 长沙营销型网站建设 长沙成交型网站建设 更多友情
  •  

    http://www.12edu.cn

     
      1. 函数ReadDat()实现从文件ENG.IN中读取一篇英文文章,存入到字符串数组xx中;请编制函数encryptChar(),按给定的替代关系对数组xx中的所有字符进行替代,仍存入数组xx的对应的位置上,最后调用函数WriteDat()把结果xx输出到文件PS10.DAT中。

      替代关系:f(p)=p*11 mod 256 (p是数组中某一个字符的ASCII值,f(p)是计算后新字符的ASCII值),如果原字符的ASCII值是偶数或计算后f(p)值小于等于32,则该字符不变,否则将f(p)所对应的字符进行替代。部分源程序已给出,原始数据文件存放的格式是:每行的宽度均小于80个字符。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。

      #include

      #include

      #include

      #include

      unsigned char xx[50][80];

      int maxline=0;/*文章的总行数*/

      int ReadDat(void)

      void WriteDat(void)

      void encryptChar()

      { int i,j;

      char *p;

      for(i=0;i='a'&&xx[j]='0'&&p='A'&&p='0'&&xx[j]='A'&&xx[j]='a'&&p130)

      ;

      else xx[j]=p; } }

      11.函数ReadDat()实现从文件in.dat中读取20行数据存放到字符串数组xx中(第行字符串长度均小于80)。请编制函数jsSort(),其函数的功能是:以行为单位对字符串按给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数WriteDat()把结果xx输出到文件out.dat中。

      条件:从字符串中间一分为二,左边部分按字符的ASCII值升序排序,排序后左边部分与右边部分进行交换。如果原字符串长度为奇数,则最中间的字符不参加处理,字符仍放在原位置上。

      例如:位置 0 1 2 3 4 5 6 7 8

       源字符串 d c b a h g f e

      4 3 2 1 9 8 7 6 5

      则处理后字符串 h g f e a b c d

      8 7 6 5 9 1 2 3 4

      部分源程序已给出。 请勿改动主函数main()、读函数ReadDat()和写函数WriteDat()的内容。

      #include

      #include

      #include

      char xx[20][80];

      void jsSort()

      { int i,j,k,m;

      char c;

      for(i=0;ixx[m])

      { c=xx[j];

      xx[j]=xx[m];

      xx[m]=c; }

      for(j=0;jxx[m])

      { c=xx[j];

      xx[j]=xx[m];

      xx[m]=c; } }

      }

      14.函数ReadDat()实现从文件in.dat中读取20行数据存放到字符串数组xx中(第行字符串长度均小于80)。请编制函数jsSort(),其函数的功能是:以行为单位对字符串变量的下标为奇数的字符按其ASCII值从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数WriteDat()把结果xx输出到文件out.dat中。

      例如:位置 0 1 2 3 4 5 6 7

       源字符串 h g f e d c b a

      则处理后字符串 h a f c d e b g

      部分源程序已给出。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。

      void jsSort()

      { int i,j,k,m;

      char c;

      for(i=0;ixx[m])

      { c=xx[j];

      xx[j]=xx[m];

      xx[m]=c; } } }

      15.函数ReadDat()实现从文件in.dat中读取20行数据存放到字符串数组xx中(第行字符串长度均小于80)。请编制函数jsSort(),其函数的功能是:以行为单位对字符串按给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数WriteDat()把结果xx输出到文件out.dat中。条件:从字符串中间一分为二,右边部分按字符的ASCII值升序排序,排序后左边部分与右边部分进行交换。如果原字符串长度为奇数,则最中间的字符不参加排序,字符仍放在原位置上。

      例如:位置 0 1 2 3 4 5 67 8

       源字符串 d c b a h g f e

      8 7 6 5 9 1 2 3 4

      则处理后字符串 e f g h d c b a

      5 6 7 8 9 4 3 2 1

       部分源程序已给出。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数 WriteDat()的内容。

      void jsSort()

      { int i,j,k,m,n;

      char c;

      for(i=0;ixx[m])

      { c=xx[j];

      xx[j]=xx[m];

      xx[m]=c; }

      for(j=0;jxx[m])

      { c=xx[j];

      xx[j]=xx[m];

      xx[m]=c; }

      if(k%2==0)

      n=k/2;

      else n=k/2+1;

      for(j=n;jn)

      { c=aa;

      aa=aa[j];

      aa[j]=c; }

      if(m==n)

      { if(aa(aa.x2+aa.x3))

      bb[k++]=aa;

      for(i=0;ibb[j].x1+bb[j].x3)

      { m=bb;

      bb=bb[j];

      bb[j]=m; }

      return k;

      }

      void main()

      { int count;

      readDat();

      count=jsSort(); /*返回满足条件的个数*/

      writeDat(count); }

      readDat(int count)

      { FILE *in;

      int i;

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

      for(i=0; ia[j].s)

      { *s=a;

      a=a[j];

      a[j]=*s; }

      return a[0].s;

      }

      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;

      clrscr();

      printf("***** The original data *****\n");

      for(i=0; i0;m++)

      if(isP(m))

      { xx[i++]=m;

      k--; } }

      main()

      {

      int m, n, xx[1000] ;

      clrscr() ;

      printf("\nPlease enter two integers:") ;

      scanf("%d%d", &m, &n ) ;

      num(m, n, xx) ;

      for(m = 0 ; m sell[j].je)

      { c=sell;

      sell=sell[j];

      sell[j]=c; } } }

      33..已知在文件IN.DAT中存有100个产品销售记录,每个产品销售记录由产品代码dm(字符型4位),产品名称mc(字符型10位),单价dj(整型),数量sl(整型),金额je(长整型)四部分组成。其中:金额=单价*数量计算得出。函数ReadDat()是读取这100个销售记录并存入结构数组sell中。请编制函数SortDat(),其功能要求:按产品名称从大到小进行排列,若产品名称相同,则按金额从大到小进行排列,最终排列结果仍存入结构数组sell中,最后调用函数WriteDat()把结果输出到文件OUT6.DAT中。

      部分源程序已给出。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。

      void SortDat()

      { int i,j;

      PRO c;

      for(i=0;isell[j].je)

      { c=sell;

      sell=sell[j];

      sell[j]=c; }

      else

      if(sell.je==sell[j].je)

      if(strcmp(sell.dm,sell[j].dm)sell[j].je)

      { c=sell;

      sell=sell[j];

      sell[j]=c; }

      else

      if(sell.je==sell[j].je)

      if(strcmp(sell.dm,sell[j].dm)>0)

      { c=sell;

      sell=sell[j];

      sell[j]=c; } } }

      37.已知在文件IN.DAT中存有100个产品销售记录,每个产品销售记录由产品代码dm(字符型4位),产品名称mc(字符型10位),单价dj(整型),数量sl(整型),金额je(长整型)四部分组成。其中:金额=单价*数量计算得出。函数ReadDat()是读取这100个销售记录并存入结构数组sell中。请编制函数SortDat(),其功能要求:按金额从大到小进行排列,若金额相等,则按产品代码从小到大进行排列,最终排列结果仍存入结构数组sell中,最后调用函数WriteDat()把结果输出到文件OUT3.DAT中。部分源程序已给出。

      请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。

      void SortDat()

      { int i,j;

      PRO c;

      for(i=0;i0)

      { c=sell;

      sell=sell[j];

      sell[j]=c; } } }

      38.已知在文件IN.DAT中存有100个产品销售记录,每个产品销售记录由产品代码dm(字符型4位),产品名称mc(字符型10位),单价dj(整型),数量sl(整型),金额je(长整型)四部分组成。其中:金额=单价*数量计算得出。函数ReadDat()是读取这100个销售记录并存入结构数组sell中。请编制函数SortDat(),其功能要求:按产品名称从小到大进行排列,若产品名称相等,则按金额从小到大进行排列,最终排列结果仍存入结构数组sell中,最后调用函数WriteDat()把结果输出到文件OUT5.DAT中。部分源程序已给出。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。

      void SortDat()

      { int i,j;

      PRO c;

      for(i=0;i0)

      { c=sell;

      sell=sell[j];

      sell[j]=c; }

      else

      if(strcmp(sell.mc,sell[j].mc)==0)

      if(sell.je>sell[j].je)

      { c=sell;

      sell=sell[j];

      sell[j]=c; } } }

      39.已知在文件IN.DAT中存有100个产品销售记录,每个产品销售记录由产品代码dm(字符型4位),产品名称mc(字符型10位),单价dj(整型),数量sl(整型),金额je(长整型)四部分组成。其中:金额=单价*数量计算得出。函数ReadDat()是读取这100个销售记录并存入结构数组sell中。请编制函数SortDat(),其功能要求:按产品名称从大到小进行排列,若产品名称相等,则按金额从小到大进行排列,最终排列结果仍存入结构数组sell中,最后调用函数WriteDat()把结果输出到文件OUT7.DAT中。部分源程序已给出。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。

      void SortDat()

      { int i,j;

      PRO c;

      for(i=0;isell[j].je)

      { c=sell;

      sell=sell[j];

      sell[j]=c; } } }

      40.已知在文件IN.DAT中存有100个产品销售记录,每个产品销售记录由产品代码dm(字符型4位),产品名称mc(字符型10位),单价dj(整型),数量sl(整型),金额je(长整型)四部分组成。其中:金额=单价*数量计算得出。函数ReadDat()是读取这100个销售记录并存入结构数组sell中。请编制函数SortDat(),其功能要求:按产品代码从小到大进行排列,若产品代码相等,则按金额从小到大进行排列,最终排列结果仍存入结构数组sell中,最后调用函数WriteDat()把结果输出到文件OUT9.DAT中。部分源程序已给出。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。

      void SortDat()

      { int i,j;

      PRO c;

      for(i=0;i0)

      { c=sell;

      sell=sell[j];

      sell[j]=c; }

      else

      if(strcmp(sell.dm,sell[j].dm)==0)

      if(sell.je>sell[j].je)

      { c=sell;

      sell=sell[j];

      sell[j]=c; } } }

      41.请编写一个函数jsvalue(int m,int k,int xx[]),该函数的功能是:将大于整数m且紧靠m的k个素数存入数组xx传回。最后调用函数writeDat()读取10组数据,分别得出结果且把结果输出到文件out.dat中。例如:若输入17,5,则应输出:19,23,29,31,37。请勿改动主函数main()和写函数writeDat()的内容。

      #include

      int ss(int k)

      { int i,j;

      j=1;

      for(i=2;i if(k%i==0) j=0;

      return j; }

      void jsvalue(int m,int k,int xx[])

      { int i=0;

      for(m=m+1;k>0;m++)

      if(ss(m))

      { xx[i++]=m;

      k--; } }

      main()

      {int m,n,zz[100];

      printr(\"\\n请输入两个整数:\");

      scanf(\"%d%d\",&m,&n);

      jsvalue(m,n,zz);

      for(m=0;maa[j])

      { k=aa;

      aa=aa[j];

      aa[j]=k; } }

      for(i=0;i(aa.x1+aa.x3))

      bb[m++]=aa;

      for(i=0;i0;m--)

      a[m]=a[m-1];

      a[0]=c; } }

      }

      main()

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

      {3,5,8,9,1,2,6,4,7},

      {8,2,1,9,3,5,4,6,7},

      {3,5,1,2,9,8,6,7,4},

      {4,7,8,9,1,2,5,3,6},

      {4,7,3,5,1,2,6,8,9},

      {9,1,3,5,8,6,2,4,7},

      {2,6,1,9,8,3,5,7,4},

      {5,3,7,9,1,8,2,6,4},

      {7,1,3,2,5,8,9,4,6}, };

      int i,j;

      jsvalue(a);

      for(i=0;i=100) b[0]=k;

      if(sn=1000) b[1]=k;

      if(sn=10000)

      { b[2]=k;

      break; }

      sn=sn+an;

      a1=a2;

      a2=an;

      k++; }

      }

      main()

      {jsvalue();

      printf(\"M=100,n=%d\\nM=1000,n=%d\\nM=10000,n=%d\\n\",b[0],b[1],b[2]);

      writeDat() }

      writeDat()

      {FILE *fp;

      fp=fopen(\"out.dat\",\"w\");

      fprintf(fp,\"%d\\n%d\\n%d\\n\",b[0],b[1],b[2]);

      fclose(fp); }

      OUT.DAT文件

      6

      9

      11

      47---56题in.dat文件

      You can create an index on any field, on several fields to be used

      together, or on parts thereof, that you want to use as a key. The

      keys in indexes allow you quick access to specific records and define

      orders for sequential processing of a ISAM file. After you no longer

      need an index, you can delete it. Addition and indexes have no effect

      on the data records or on other indexes.

      You may want a field in field in each record to uniquely identify that

      record from all other records in the file. For example, the Employee

      Number field is unique if you do not assign the same number to two

      different employees, and you never reassign these numbers to other

      employees. If you wish to find or modify the record belonging to a

      specific employee, this unique field saves the thouble of determining

      whether you have the correct record.

      If you do not have a unique field, you must find the first record

      the matches your key and determine whether the record is the one you

      want. If it is not the correct one, you must search again to find others.

      If you know that you have a unique field within your records, you

      can include this fact in the key description, and ISAM will allow only

      unique keys. For example, if you specify that the employee numbers are

      unique, ISAM only lets you add records to the file for, or change

      numbers to, employee numbers that do not alreadly exist int file.

      47..函数ReadDat()实现从文件IN.DAT中读取一篇英文文章存 入到字符串数组xx中,请编制函数CharConvA(),其函数的功能是:以行为单位把字符串中的最后一个字符的ASCII值右移4位后加最后第二个字符的ASCII值,得到最后一个新的字符,最后第二个字符的ASCII值右移4位后加最后第三个字符的ASCII值,得到最后第二个新的字符,依此类推一直处理到第二个字符,第一个字符的ASCII值加原最后一个字符的ASCII值,得到第一个新的字符,得到的新字符分别存放在原字符串对应的位置上。最后已处理的字符串仍按行重新存入字符串数组xx中,最后调用函数writeDat()把结果xx输出到文件OUT10.DAT中。原始数据文件存放的格式是:每行的宽度均小于80个字符,含标点符号和空格。部分源程序已给出。请勿改动主函数main()和写函数writeDat()的内容。

      #include

      #include

      #include

      char xx[50][80] ;

      int maxline = 0 ; /* 文章的总行数 */

      int ReadDat(void) ;

      void WriteDat(void) ;

      void CharConvA(void)

      { int i,j;

      char p,c;

      for(i=0;i { p=xx[strlen(xx)-1];

      c=xx[0];

      for(j=strlen(xx)-1;j>0;j--)

      xx[j]=(xx[j]>>4)+xx[j-1];

      xx[0]=p+c; }

      }

      void main()

      {

      clrscr() ;

      if(ReadDat()) {

      printf("数据文件IN.DAT不能打开!\n\007") ;

      return ;

      }

      CharConvA() ;

      WriteDat() ;

      }

      int ReadDat(void)

      {

      FILE *fp ;

      int i = 0 ;

      char *p ;

      if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;

      while(fgets(xx, 80, fp) != NULL) {

      p = strchr(xx, ''\n'') ;

      if(p) *p = 0 ;

      i++ ;

      }

      maxline = i ;

      fclose(fp) ;

      return 0 ;

      }

      void WriteDat(void)

      {

      FILE *fp ;

      int i ;

      clrscr() ;

      fp = fopen("OUT10.DAT", "w") ;

      for(i = 0 ; i >4)+xx[j];

      }

      void main()

      {

      clrscr() ;

      if(ReadDat()) {

      printf("数据文件IN.DAT不能打开!\n\007") ;

      return ;

      }

      StrCharJR() ;

      WriteDat() ;

      }

      int ReadDat(void)

      {

      FILE *fp ;

      int i = 0 ;

      char *p ;

      if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;

      while(fgets(xx, 80, fp) != NULL) {

      p = strchr(xx, '\n') ;

      if(p) *p = 0 ;

      i++ ;

      }

      maxline = i ;

      fclose(fp) ;

      return 0 ;

      }

      void WriteDat(void)

      {

      FILE *fp ;

      int i ;

      clrscr() ;

      fp = fopen("OUT8.DAT", "w") ;

      for(i = 0 ; i ='b'&&xx[j]100))

      xx[j]+=c; }

      }

      void main()

      {

      clrscr() ;

      if(ReadDat()) {

      printf("数据文件IN.DAT不能打开!\n\007") ;

      return ;

      }

      StrCharJL() ;

      WriteDat() ;

      }

      int ReadDat(void)

      {

      FILE *fp ;

      int i = 0 ;

      char *p ;

      if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;

      while(fgets(xx, 80, fp) != NULL) {

      p = strchr(xx, ''\n'') ;

      if(p) *p = 0 ;

      i++ ;

      }

      maxline = i ;

      fclose(fp) ;

      return 0 ;

      }

      void WriteDat(void)

      {

      FILE *fp ;

      int i ;

      clrscr() ;

      fp = fopen("OUT7.DAT", "w") ;

      for(i = 0 ; i 100))

      xx[j]+=c; }

      }

      void main()

      {

      clrscr() ;

      if(ReadDat()) {

      printf("数据文件IN.DAT不能打开!\n\007") ;

      return ;

      }

      StrCharJL() ;

      WriteDat() ;

      }

      int ReadDat(void)

      {

      FILE *fp ;

      int i = 0 ;

      char *p ;

      if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;

      while(fgets(xx, 80, fp) != NULL) {

      p = strchr(xx, ''\n'') ;

      if(p) *p = 0 ;

      i++ ;

      }

      maxline = i ;

      fclose(fp) ;

      return 0 ;

      }

      void WriteDat(void)

      {

      FILE *fp ;

      int i ;

      clrscr() ;

      fp = fopen("OUT7.DAT", "w") ;

      for(i = 0 ; i 想要全部的请留信箱啊!

     

    ......
    本文标签: 计算机等级考试 
  • 招考