链表的实 现

青山绿水之辈 2013-07-22 09:33:06

#include<iostream>
#include<cstring>
using namespace std;
int main()
{
__int64 t,n,i,str[55][26],j;
char ch1[1000],ch2[1000];
cin>>t;
while(t--)
{
memset(str,0,sizeof(str));
cin>>ch1>>ch2>>n;
//cout<<ch2;
for(i=0;ch1[i]!='\0';i++)
{
str[0][ch1[i]-'a']++;//str[n][0]代表a字符在第n个串中的个数
}


for(i=0;ch2[i]!='\0';i++)
str[1][ch2[i]-'a']++;

for(i=2;i<=n;i++)
for(j=0;j<26;j++)
str[i][j]=str[i-1][j]+str[i-2][j];

for(j=0;j<26;j++)
cout<<(char)('a'+j)<<':'<<str[n][j]<<endl;
cout<<endl;
}
}
...全文
111 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧