hdu 4054 字符串处理

文章描述了一次比赛中遇到难题导致心理紧张的经历,并分享了通过实际操作解决难题后,认识到赛场心理素质训练的重要性。作者提到,良好的心理素质对于正式比赛时发挥最佳水平至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

现场赛中最水的题,发现这题时比赛已经进行了半个小时,可是我打了半个小时还没有搞定,看着旁边的队伍一个个地升起气球,更加紧张,后面还有一点小问题干脆让海峰写了。今天发现杭电加了现场赛的题目,20分钟就把这题给过了。看来赛场上的心理素质还得训练,不然正式比赛的时候难以发挥出最好的水平~

/*
* hdu4054/win.cpp
* Created on: 2011-10-6
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
const int MAX_LEN = 4200;
char ori[MAX_LEN], newstr[MAX_LEN];

void work() {
strcpy(newstr, ori);
int len = strlen(ori);
for (int i = 0; i < len; i++) {
if (newstr[i] >= 'A' && newstr[i] <= 'Z') {
newstr[i] += 32;
} else if (newstr[i] >= 'a' && newstr[i] <= 'z') {
newstr[i] -= 32;
}
}
int I = 0;
while (I * 16 + 16 <= len) {
printf("%04x: ", I * 16);
for (int j = 0; j < 16; j += 2) {
printf("%x%x ", ori[I * 16 + j], ori[I * 16 + j + 1]);
}
for (int j = 0; j < 16; j++) {
putchar(newstr[I * 16 + j]);
}
putchar('\n');
I++;
}
if (I * 16 < len) {
int J = len - I * 16;
printf("%04x: ", I * 16);
for (int j = 0; j < J - 1; j += 2) {
printf("%x%x ", ori[I * 16 + j], ori[I * 16 + j + 1]);
}
if (J % 2 == 1) {
printf("%x ", ori[I * 16 + J - 1]);
}
int K = 16 - J;
for (int j = 0; j < K - 1; j += 2) {
printf(" ");
}
for (int j = 0; j < J; j++) {
putchar(newstr[I * 16 + j]);
}
putchar('\n');
}
}

int main() {
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif
while (gets(ori)) {
work();
}
return 0;
}



转载于:https://www.cnblogs.com/moonbay/archive/2011/10/06/2199952.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值