3没有过,求好心人帮助!!!!(数据范围问题?)
查看原帖
3没有过,求好心人帮助!!!!(数据范围问题?)
866969
telankesi楼主2023/1/6 20:54
#include <stdio.h>
#include <string.h>
long long fun1(long long x) {
	long long t = 0;
	while (x != 0) {
		t = t * 10 + x % 10;
		x /= 10;
	}
	return t;

}
int main() {
    char a[100];
	int len=0;
	char c=0;
	scanf("%s", &a);
long long x = 0, y = 0;
	for (int i = 0; i < strlen(a); i++) {
		if (a[i] == '.'||a[i]=='/') { c = a[i]; len = i; break; }
		if (a[i] == '%')c = a[i];
		else x = x * 10 + a[i] - '0';
	}
	if (c == '.' || c == '/') {
		for (int i = len + 1; i < strlen(a); i++) {
			y = y * 10 + a[i] - '0';
		}
	}
	x = fun1(x);
	if (c == '.' || c == '/') {
		y = fun1(y);
		printf("%lld%c%lld", x, c, y);
	}
	else if (c == '%')printf("%lld%c", x, c);
	else
	printf("%lld", x);
	return 0;
}
2023/1/6 20:54
加载中...