题解 | #skew数#

skew数

https://www.nowcoder.com/practice/5928127cc6604129923346e955e75984

#include <stdio.h>
#include<string.h>
#include <math.h>
int main() {
	char skew[32] = { 0 };
	while (scanf("%[^\n]%*c", skew) != EOF) {
		//printf("%d\n", skew[1]-'0');
		int number=0;
		for (int i = 0; i < strlen(skew); i++) {
			number += (skew[i]-'0') * (pow(2,(strlen(skew) - i)) - 1);
		}
		printf("%d\n", number);
	}
	return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务