[Codeforces Round #154 (Div. 2)]A. Boys and Girls

地址:http://codeforces.com/contest/253/problem/A

一开始没意识到文件输入输出

学会了freopen函数,长知识了,这样直接用stdin和stdout,很方便

这题很简单,输出相邻两位性别不同的个数最多的一种情况

 1 #include<stdio.h>
 2 
 3 int m,n;
 4 
 5 int main()
 6 {
 7     freopen("input.txt","r",stdin);
 8     freopen("output.txt","w",stdout);
 9     scanf("%d %d",&m,&n);
10     if(m>=n)
11     {
12         while(m!=0 || n!=0)
13         {
14             if(m!=0) {m--;printf("B");}
15             if(n!=0) {n--;printf("G");}
16         }
17     }
18     else
19     {
20         while(m!=0 || n!=0)
21         {
22             if(n!=0) {n--;printf("G");}
23             if(m!=0) {m--;printf("B");}
24         }
25     }
26     printf("\n");
27     return 0;
28 }

 

posted @ 2013-01-17 23:23  tjsuhst  阅读(219)  评论(0)    收藏  举报