当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
2015年计算机等级考试二级c语言上机题库(一)
发布时间:2012/5/21 11:26:41 来源:城市网学院 编辑:ziteng
  -
  上机题库版模拟系统中的解法
  /*在无忧模拟系统中没通过测试(输入文件句末有标点的在输出文件中句前无空格*/
  void StrOL(void)
  {
  int i, j ;
  char word[21], yy[80], zz[80], *p ;
  for(i = 0 ; i < maxline ; i++) {
  p = xx[i] ;
  j = 0 ;
  memset(word, 0, 21) ;
  memset(yy, 0, 80) ;
  while(*p) {
  if(isalpha(*p)) {
  word[j++] = *p++ ;
  if(*p) continue ;
  }
  strcpy(zz, yy) ;
  sprintf(yy, "%s %s", word, zz) ;
  j = 0 ;
  memset(word, 0, 21) ;
  while(*p && (!isalpha(*p))) p++ ;
  }
  strcpy(xx[i], yy) ;
  }
  }
  另一解法():
  /*在无忧及上机题库版模拟系统中都通过测试(输入文件句末有标点的在输出文件中句前有空格*/
  void StrOL(void)
  { int i,j,m;
  char str[80];
  for(i=0;i
  { m=strlen(xx[i]);
  memset(str,0,80);
  for(j=m-1;j>=0;j--)
  if(!isalpha(xx[i][j]))
  { strcat(str,xx[i]+j+1);
  strcat(str," ");
  xx[i][j]='\0';
  }
  strcat(str,xx[i]);
  strcpy(xx[i],str);
  }
  }
  实际上机考试时上面几种解法都可以采用。
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved