#大佬救救!自己测试是对的,但是前五个一直RE!救救!
查看原帖
#大佬救救!自己测试是对的,但是前五个一直RE!救救!
879389
goallllout楼主2023/1/31 20:19
#include<stdio.h>
#include<stdlib.h>
long long zhuan(long long n) {
	long long i, j, x=0;		
	if (n == 0)return 0;
		i = n; j = i % 10;
		while (j == 0) {
			i = i / 10; j = i % 10;
		}
		while (i != 0) {
			x = x * 10 + j;
			i = i / 10;
			j = i % 10;
		}
	return x;
}
int main() {
	char ch[1000] = { 0 },sh[1000]={0};
	long long i, j=1, sum = 0, x,y;
	i = 0;
	ch[i] = getchar();
		for (i = 1;; i++) {
			ch[i] = getchar();
			if (ch[i] == '.') {
				sh[0] = '.';
				ch[i] = '\0';
				x = (atoll)(ch);
				scanf("%lld", &y);
				while (y!=0&&y % 10 == 0) {
					y = y / 10;
					sh[j] = '0';
					j++;
				}
				printf("%lld%s%lld", zhuan(x),sh, zhuan(y));
				return 0;
			}
			if (ch[i] == '/') {
				sh[0] = '/';
				ch[i] = '\0';
				x = (atoll)(ch);
				scanf("%lld", &y);
				printf("%lld%c%lld",zhuan(x),sh[0], zhuan(y));
				return 0;
			}
			if (ch[i] == '%') {
				x = 1;
				sh[0] = '%';
				ch[i] = '\0';
				x = (atoll)(ch);
				printf("%lld%c",zhuan(x),sh[0]);
				return 0;
			}
			if (ch[i] == '\n') {
				x = (atoll)(ch);
				printf("%lld", zhuan(x));
				return 0;
			}
		}
}
2023/1/31 20:19
加载中...