Problem Type : String
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main()
{
int i,j,k,n,cou;
map <int ,string >cp;
string str [16]= {"Happy" ,"birthday", "to", "you", "Happy", "birthday", "to", "you" ,"Happy", "birthday", "to", "Rujia", "Happy", "birthday", "to", "you"};
cin >> n;
for(i=0; i<n; i++)
{
cin >>cp[i];
}
if(n>16)
{
j=0;
cou=0;
for(i=0; ; i++)
{
if(cou==1 && i==16)
break;
if(j==n)
{
j=0;
cou=1;
}
if(i==16)
{
i=0;
}
cout <<cp[j] <<':'<<' ' <<str[i] <<endl;
j++;
}
}
else if(n<=16)
{
j=0;
for(i=0; i<16; i++)
{
if(j==n)
{
j=0;
}
cout <<cp[j] <<':'<<' ' <<str[i] <<endl;
j++;
}
}
}
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main()
{
int i,j,k,n,cou;
map <int ,string >cp;
string str [16]= {"Happy" ,"birthday", "to", "you", "Happy", "birthday", "to", "you" ,"Happy", "birthday", "to", "Rujia", "Happy", "birthday", "to", "you"};
cin >> n;
for(i=0; i<n; i++)
{
cin >>cp[i];
}
if(n>16)
{
j=0;
cou=0;
for(i=0; ; i++)
{
if(cou==1 && i==16)
break;
if(j==n)
{
j=0;
cou=1;
}
if(i==16)
{
i=0;
}
cout <<cp[j] <<':'<<' ' <<str[i] <<endl;
j++;
}
}
else if(n<=16)
{
j=0;
for(i=0; i<16; i++)
{
if(j==n)
{
j=0;
}
cout <<cp[j] <<':'<<' ' <<str[i] <<endl;
j++;
}
}
}
No comments:
Post a Comment