POJ 3673 Cow Multiplication 题解(gcc) - 哆啦比猫的技术瞎扯 - Arch Linux · ドラえもん · 实时绘制

POJ 3673 Cow Multiplication 题解(gcc)

哆啦比猫 posted @ 2011年8月20日 11:33 in OI with tags OI POJ , 1613 阅读

http://poj.org/problem?id=3673  灵活运用指针


#include <stdio.h>

char isd(int i)
{
	return i>=0 && i<10;
}

int main(void)
{
	char a[11], b[11];
	char * ap = a;
	char * bp = b;

	while (isd(*ap++ = getchar() - '0')) {}
	*--ap = -1;
	while (isd(*bp++ = getchar() - '0')) {}
	*--bp = -1;

	ap = a;

	int result = 0;
	while (*ap != -1) {
		bp = b;
		while (*bp != -1)
			result += (*ap) * (*bp++);
		ap++;
	}

	printf("%d\n", result);

	return 0;
}

凡未特殊声明(转载/翻译),所有文章均为原创。
by Giumo Xavier Clanjor (哆啦比猫/兰威举), 2010-2019.
知识共享许可协议本作品采用知识共享署名·非商业性使用·相同方式共享 3.0 中国大陆许可协议进行许可。
文中凡未特殊声明且未声明为引用的代码均以 MIT 协议授权。

blog comments powered by Disqus
© 2010-2019 Giumo Xavier Clanjor (哆啦比猫/兰威举).
© 2013, 2014, 2015-2016 and 2017 The Dark Colorscheme Designed by Giumo Xavier Clanjor (哆啦比猫/兰威举).
知识共享署名·非商业性使用·相同方式共享 3.0 中国大陆许可协议
| © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee