求助,全是RE
查看原帖
求助,全是RE
528155
sylg_thumb楼主2021/6/23 23:01

在自己电脑上一切都正常,猜测是测试时没读出换行导致程序一直不终止,但为什么读不出来呢?

//10 enter
//42 *
//45 -
//97-122 a-z type1
//65-90 A-Z type2
//48-57 0-9 type3
//p1 1a2A3*
//p2 times
//p3 1-> 2<-
#include<stdio.h>
void print(char a,int times)
{
	int i;
	for(i=0;i<times;i++)
		printf("%c",a);
}
char type(char a)
{
	if((a>47)&&(a<58))
		return 3;
	else if((a>64)&&(a<91))
		return 2;
	else if((a>96)&&(a<123))
		return 1;
	else
		return 0;
}
char check(char last,char next)
{
	if(type(last)-type(next))
		return 0;
	else if(!type(last))
		return 0;
	else if(last==next)
		return 0;
	else
		return 1;
}
void out(char last,char next,int p1,int p2,int p3)
{
	char i,start,end,step;
	start=p3-2?last+1:next-1;
	end=p3-2?next:last;
	step=p3-2?1:-1;
	for(i=start;i-end;i+=step)
		if(p1==3)
			print(42,p2);
		else if(type(i)==3)
			print(i,p2);
		else
			print(i-(p1-type(i))*32,p2);
	printf("%c",next);
	return;
}
int main(void)
{
	int p1,p2,p3;
	scanf("%d%d%d",&p1,&p2,&p3);
	char tmp,last=0,next=0;
	scanf("%c");
	do
	{
		scanf("%c",&tmp);
		if(tmp==45)
		{
			scanf("%c",&next);
				if(check(last,next))
					out(last,next,p1,p2,p3);
				else
					printf("-%c",next);
			last=next;
		}
		else
		{
			last=tmp;
			printf("%c",tmp);
		}
	}
	while(tmp-10);
	return 0;
}
2021/6/23 23:01
加载中...