虽说是白书的入门题,但对细节的考察,不得不令人崩溃。。。(能力还是太水了)
// [4/6/2014 Sjm]
uva 10055:
/*
1) vice versa 单词含义: 反之亦然
2)注意!!!
unsigned int 无符号4字节整形 0 ~ 2^32 -1
int 4字节整形 - 2^31 ~ 2^31 - 1
__int64 或 long long 64位(8字节)整形 - 2^63 ~ 2^63 - 1
*/
#include <iostream>
#include <cstdio>
#include <cstdlib> // 使用 long long 必有此头文件
#include <cmath>
using namespace std;
typedef long long ll;
int main()
{
ll a, b;
while (scanf("%lld %lld", &a, &b) != EOF)
printf("%lld\n", abs(b-a));
return 0;
}
uva 457 :
/*
注意:
1)最后一个测试用例不用输出 '\n'
2)最后输出时,用 空格 代替 'b'
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
const int MAX_N = 42, MAX_M = 10;
int ans[2][MAX_N], myrule[MAX_M], mycount;
const char ch[4] = { ' ', '.', 'x', 'W' };
void myOutput()
{
for (int i = 1; i <= 40; i++)
{
printf("%c", ch[ans[mycount%2][i]]);
}
printf("\n");
}
void Solve()
{
mycount++;
for (; mycount <= 50; mycount++)
{
for (int i = 1; i <= 40; i++)
{
ans[mycount % 2][i] = myrule[ans[(mycount - 1) % 2][i - 1] + ans[(mycount - 1) % 2][i] + ans[(mycount - 1) % 2][i + 1]];
}
myOutput();
}
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int T;
scanf("%d", &T);
while (T--)
{
mycount = 1;
for (int i = 0; i < MAX_M; i++)
scanf("%d", &myrule[i]);
memset(ans, 0, sizeof(ans));
ans[mycount%2][20] = 1;
myOutput();
Solve();
if (T) printf("\n");
}
return 0;
}
/*
注意:
1)两个字符之间并不一定是用 空格 进行区分,亦有可能是逗号等
2)最后一个单词需特殊考虑,可能后面没有 非字母字符,可以加上一个 非字母字符 进行判断。
3)按照 !myJudge(i-1) && myJudge(i) 判断过不掉,不知为什么(此时设 sum 初始值为 1, i 初始值为1)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;
string str;
bool myJudge(int i)
{
if ((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z')) return true;
else return false;
}
int Solve()
{
int sum = 0;
int mylen = str.size();
str += ".";
for (int i = 0; i < mylen; i++){
if (myJudge(i) && !myJudge(i+1))
sum++;
}
return sum;
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
while (getline(cin, str))
printf("%d\n", Solve());
return 0;
}