ITAT 第五届c复赛b卷附加题答案

来源:互联网 发布:微信免签约接口源码 编辑:程序博客网 时间:2024/04/28 10:39

#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include<ctype.h>
void InverseByWord(char *sentence,int z)
{
int i,j,m,k,p,q;
char shift[200];
int temp[200];

temp[0]=0;
for(i=0,k=1;i<z;i++)
    if(isspace(sentence[i]))
       temp[k++]=i;
    temp[k]=z-1;
 shift[0]='.';
for(j=1,i=k;i>=1;i--)
  for(p=temp[i]-1,q=temp[i-1];p>=q;q++)
    shift[j++]=sentence[q];
     
  
shift[0]=' ';
shift[1]='.'; 
for(i=0;i<z;i++)
printf("%c",shift[i]);
printf("/n");
}

 


void main()
{
char *term=(char *)malloc(200*sizeof(char));

int i=0;
memset(term,'0',200);
while(1)
{
scanf("%c",&term[i++]);
getchar();
if(term[i-1]=='.')
      break;
}
InverseByWord(term,i);


}