CodeFoeces-705A

题目

原题链接:A. Hulk

题意

布兰特博士对他的敌人有特别的感情,输入一个n,若 n = 1, 感情变成 "I hate it" ,若 n = 2, "I hate that I love it", 当 n = 3 "I hate that I love that I hate it"。需要注意大于1时it变成了that。

代码

#include
using namespace std;
int main()
{
    char hate[]={"I hate "};
    char love[]={"I love "};
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){ 
        if(i%2==0){
            printf("%s",love);
        }else{
            printf("%s",hate);
        } 
        if(i==n){
            printf("it\n");
        }else{
            printf("that ");
        }
    }
    return 0;
}

你可能感兴趣的:(CodeFoeces-705A)