Re: 10152 - ShellSort
Posted: Tue Mar 19, 2013 11:53 pm
Don't print a blank line at the start of the output. Don't print a space on the blank lines.
Code: Select all
#define MAX 81
#define NMAX 200
/**/
#include <stdio.h>
#include <string.h>
/**/
int T,n,i,j;
char fr[NMAX][MAX],to[NMAX][MAX];
/**/
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d\n",&n);
for(i=0; i<n; i++)
gets(fr[i]);
for(i=0; i<n; i++)
gets(to[i]);
j=n-1;
for(i=n-1; i>=0; i--)
if(strcmp(fr[i],to[j]) == 0)
j--;
for(i=j; i>=0; i--)
printf("%s\n" , to[i]);
printf("\n");
}
return 0;
}
Welcome to Programming Challenges
This site is still in beta testing and several features are not yet completely stable. If you experience problems, please
(1) let us know by reporting them to revilla@mac.uva.es and
(2) test your submissions on the UVa Online Judge as well.
Some users have reported difficulties with Java, but C/C++ programs should work fairly reliably. Due to differences in compilers and operating systems, the two judges are not completely consistent, meaning that a program might get accepted by one judge but not the other. Do not feel too bad if the judge won't accept a program you are sure is correct, because it does not administer perfect justice. Do the best that you can and have fun with it!
thanks Mr. lightedlighted wrote:The following text is written here http://www.programming-challenges.com/pg.php?page=index