CodeForces 705A(训练水题)

题目链接:http://codeforces.com/problemset/problem/705/A

从第三个输出中可看出规律,

I hate that I love that I hate it
I hate 
I love 
是来回循环的,不到最后一个每一次循环后面都输出 that,如果到最后则输出 it
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     char a[2][20]= {"I love ","I hate "};
 6     int n;
 7     while(~scanf("%d",&n))
 8     {
 9         int x=1;
10         for(int i=0; i<n; i++)
11         {
12             printf("%s",a[x]);
13             if(i!=(n-1))
14                 printf("that ");
15             x=!x;
16         }
17         printf("it
");
18     }
19 
20     return 0;
21 }
原文地址:https://www.cnblogs.com/A--Q/p/5769004.html