Monday, 2 March 2015

Uva-12554 - A Special Happy Birthday Song solution

/*Uva-12554 - A Special Happy Birthday Song Solution*/

Solution:

#include<bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main(){

    string name[110],song[] = {"Happy","birthday","to","you","Happy","birthday","to","you","Happy","birthday","to","Rujia","Happy","birthday","to","you"};
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> name[i];
    }
    int j = 0,k = 0,m = 1;
    if(n > 16)m = ceil(n/16)+1;
    for(int i = 0; i < m*16; i++,j++,k++){
        if(k == 16)k = 0;
        if(j == n)j = 0;
        cout << name[j] << ": " << song[k] << endl;
    }
    return 0;
}

No comments:

Post a Comment