uva 10055 uva 457 uva 494

虽说是白书的入门题,但对细节的考察,不得不令人崩溃。。。(能力还是太水了)

//  [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;
}


uva 494:

/*
注意:
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;
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值