编程之美第1题,真心表示玩不转
来源:互联网 发布:网络教育毕业证怎么拿 编辑:程序博客网 时间:2024/05/02 01:23
#include <iostream>
#include <fstream>
#include <string.h>
#include <sstream>
using namespace std;
int main(int argc,char *argv[])
{
int T;
cin>>T;
ostringstream* os=new ostringstream[T];
char* index=NULL;
char* indexx=NULL;
char* index2=NULL;
int caseNo=0;
while(T!=0)
{
int M;
int N;
cin>>M>>N;
string* str=new string[2*N];
for(int i=0;i<2*N;i=i+2)
{
string x1,x2;
cin>>x1>>x2;
str[i]=x1;
str[i+1]=x2;
}
char Mystring[100];
getchar();
cin.getline(Mystring,100);
indexx=Mystring;
int num=0;
while(*indexx!=' ')
{
indexx++;
if(*indexx==' ') { num++; indexx++;}
if(*indexx==0) { num++; break;}
}
indexx=Mystring;
string *mystring=new string[num];
int count1=0;
int count2=0;
for(int ii=0;ii<num;ii++)
{
while(*indexx!=' ')
{
if(*indexx=='\0') break;
indexx++;
count2++;
}
char xxx1[20];
memcpy(xxx1,Mystring+count1,count2-count1);
xxx1[count2-count1]='\0';
mystring[ii]=xxx1;
if(*indexx=='\0') break; //结束for语句
++count2;
count1=count2;
indexx++;
}
os[caseNo]<<"case #"<<caseNo+1<<":";
bool find=false;
for(int m=0;m<num;m++)
{
for(int nTimes=1;nTimes<=M-1;++nTimes)
{
find=false;
for(int n=0;n<=N-1;++n)
{
if(mystring[m]==str[2*n])
{ mystring[m]=str[2*n+1]; find=true; break;}
}
if(!find) break;
}
os[caseNo]<<mystring[m]<<" ";
}
cout<<os[caseNo].str()<<endl;
delete [] mystring; mystring=NULL;
delete [] str; str=NULL;
T--;
caseNo++;
}
return 0;
}
#include <fstream>
#include <string.h>
#include <sstream>
using namespace std;
int main(int argc,char *argv[])
{
int T;
cin>>T;
ostringstream* os=new ostringstream[T];
char* index=NULL;
char* indexx=NULL;
char* index2=NULL;
int caseNo=0;
while(T!=0)
{
int M;
int N;
cin>>M>>N;
string* str=new string[2*N];
for(int i=0;i<2*N;i=i+2)
{
string x1,x2;
cin>>x1>>x2;
str[i]=x1;
str[i+1]=x2;
}
char Mystring[100];
getchar();
cin.getline(Mystring,100);
indexx=Mystring;
int num=0;
while(*indexx!=' ')
{
indexx++;
if(*indexx==' ') { num++; indexx++;}
if(*indexx==0) { num++; break;}
}
indexx=Mystring;
string *mystring=new string[num];
int count1=0;
int count2=0;
for(int ii=0;ii<num;ii++)
{
while(*indexx!=' ')
{
if(*indexx=='\0') break;
indexx++;
count2++;
}
char xxx1[20];
memcpy(xxx1,Mystring+count1,count2-count1);
xxx1[count2-count1]='\0';
mystring[ii]=xxx1;
if(*indexx=='\0') break; //结束for语句
++count2;
count1=count2;
indexx++;
}
os[caseNo]<<"case #"<<caseNo+1<<":";
bool find=false;
for(int m=0;m<num;m++)
{
for(int nTimes=1;nTimes<=M-1;++nTimes)
{
find=false;
for(int n=0;n<=N-1;++n)
{
if(mystring[m]==str[2*n])
{ mystring[m]=str[2*n+1]; find=true; break;}
}
if(!find) break;
}
os[caseNo]<<mystring[m]<<" ";
}
cout<<os[caseNo].str()<<endl;
delete [] mystring; mystring=NULL;
delete [] str; str=NULL;
T--;
caseNo++;
}
return 0;
}
- 编程之美第1题,真心表示玩不转
- 编程之美第1题-扩展
- [编程之美]求二进制表示中1的个数
- 编程之美2013全国挑战赛资格赛第1题
- 微软编程之美2013全国挑战赛 初赛第1场 第2题
- 编程之美之第k大数
- 编程之美2013全国挑战赛资格赛第3题
- 2015微软编程之美挑战赛初赛第1场
- 编程之美1
- 编程之美1——一个数的二进制表示中1的个数
- 《编程之美》:整数的二进制表示中1的个数
- 编程之美 2.1 求一个数的二进制表示中1的个数
- <编程之美>求一个整数的二进制表示1的个数
- 编程之美-2.2、n阶乘的二进制表示中最低位1的位置
- 编程之美---求N!的二进制表示中最低位1的位置
- 编程之美2——N!的二进制表示中最低位1的位置
- 编程之美 - 浮点数的精确表示
- 微软编程之美2013全国挑战赛 资格赛 第1题
- 黑马程序员_接口整理
- 判断一个邮箱地址是否合格
- PHP抓取页面
- 字符编解码的故事(ASCII,ANSI,Unicode,Utf-8)
- 工作任务的顺序安排
- 编程之美第1题,真心表示玩不转
- 工作一年多的感想
- 编写程序,打印输入中单词长度的直方图(up/down/left/right)
- 第四堂课后作业
- 国家信息化专家咨询委员会常务副主任周宏仁
- arch无线网手动连接
- C语言实现的linux下ls命令
- POJ 1094 Sorting It All Out
- C语言----------字符串小程序练习(二)