Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct reg{
- char* letter;
- }Treg;
- typedef struct reg1{
- char let[20];
- }Treg1;
- int main(int argc, char** argv) {
- Treg song[16];int n;
- song[0].letter="Happy";song[1].letter="birthday";song[2].letter="to";
- song[3].letter="you";song[4].letter="Happy";song[5].letter="birthday";
- song[6].letter="to";song[7].letter="you";song[8].letter="Happy";
- song[9].letter="birthday";song[10].letter="to";song[11].letter="Rujia";
- song[12].letter="Happy";song[13].letter="birthday";song[14].letter="to";
- song[15].letter="you";
- int cont=0;int cont1=0;int i,j;
- Treg1 singers[100];
- while(scanf("%d",&n)==1)
- {
- char buffer[20]; char buf1[20];
- for (i=0;i<20;i++) buffer[i]=0;
- for (i=0;i<20;i++) buf1[i]=0;
- for (i=0;i<n;i++){
- scanf("%s",&buffer);
- for (j=0;j<strlen(buffer);j++){
- singers[i].let[j]=buffer[j];
- }
- singers[i].let[j]='\0';
- }
- if (n<16){
- while (cont<16){
- i=0;
- while((i<n) && (cont!=16)){
- printf("%s: %s\n",singers[i].let,song[cont].letter);
- cont++;i++;
- }
- }
- }else{
- while(cont<n){
- i=0;
- while(i<16 && cont!=n){
- printf("%s: %s\n",singers[cont].let,song[i].letter);
- cont++;i++;
- }
- }
- if(cont==n && i!=16){
- cont=0;
- for(j=i;j<16;j++){
- printf("%s: %s\n",singers[cont].let,song[j].letter);
- cont++;i++;
- }
- }
- }
- }
- return (EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement