藏头诗

| January 3, 2008 18:45 | timmy | Via Original
所谓藏头诗,就是将这首诗每一句的第一个字(1个汉字占2个字符)连起来,所组成的
内容就是该诗的真正含义。编写一个函数char  *change(char  s[4][20])实现藏头诗的解密。
输入一首藏头诗(假设只有4句),输出其真实含义。
例:
输入:
一叶轻舟向东流,
帆稍轻握杨柳手。
风纤碧波微起舞,
顺水任从雅客流。
输出:
一帆风顺




#include <stdio.h>
char p[16];
void main()
{
  char  *change(char s[4][20]);
  char  s[4][20];
  int  i;
  for(i=0;i<4;i++)
    scanf("%s",s[i]);
  puts(change(s));
}
char  *change(char  s[4][20])
{
  int  i,t,k;
  k=0;
  for(i=0;i<4;i++)
    for(t=0;t<2;t++)
      p[k++]=s[i][t];
  return (p);
}
Tags:
Program/Code » C/C++ | Comments(0) | Trackbacks(0) | Reads(172)
Add a comment
 Site URI
 Email
  Password Optional
 Nickname  *  [Register]
               

 
Emots
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
Enable HTML
Enable UBB
Enable Emots
Hidden
Remember