码迷,mamicode.com
首页 > 其他好文 > 详细

Hashmat the Brave Warrior

时间:2014-10-16 20:04:33      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   for   strong   

Hashmat the Brave Warrior

XX自己有士兵a人, 敌军有士兵b人,自己的士兵永远比敌军少, 求对方比自己多多少人。       (虽说要从头刷,但是这样的还是太水了吧 2333333

喜闻乐见的错了因为2^32爆了int。。。These two numbers in each line denotes the number of soldiers in Hashmat‘s army and his opponent‘s army or vice versa

bubuko.com,布布扣
1 #include <cstdio>
2 int main() {
3      long long a, b;
4      while (scanf("%lld%lld", &a, &b) != EOF) {
5          long long ans = b - a > 0 ? b - a : a - b;
6          printf("%lld\n", ans);
7      }
8      return 0;
9 }
View Code

 

Rotating Sentences

把一篇文章顺时针旋转90° 看起来挺简单操作起来有点难度。。。               关键的地方在于如果是文章结尾,用空格补全    (读题的时候没读出这个意思)

bubuko.com,布布扣
#include <cstdio>
#include <cstring>
const int N = 110;
char mapp[N][N];
int len[N];

int main() {
    //freopen("in.txt", "r", stdin);
    int i = 0, maxlen = 0;
    memset(mapp, \0, sizeof(mapp));
    while (gets(mapp[i]) != NULL) i++;
    for (int j = 0; j < i; j++) {
        len[j] = strlen(mapp[j]);
        maxlen = maxlen > len[j] ? maxlen : len[j];
    }
    for (int j = 0; j < maxlen; j++) {
        for (int k = i-1; k >= 0; k--) {
            if (j >= len[k]) putchar( );
            else putchar(mapp[k][j]);
        }
        puts("");
    }

    return 0;
}
View Code

 

Hashmat the Brave Warrior

标签:style   blog   http   color   io   os   ar   for   strong   

原文地址:http://www.cnblogs.com/chbeater/p/4029321.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!