Question: the inverse order of the table

Time Limit: 1000MS Memory Limit: 10000KB
Submissions: 9 Accepted: 0
Description establishes the length of the order of N table, and then the data element in the table against the home, even if the original data elements in a sequence table (A0, A1, A2 for,... , an), then the inverse elements of data placement sequence (an, an-1, an-2,... , A1, A0). (data type for the character)

The length of n Input first action sequence table,
Second data elements in the sequence table,

The Output output is reversed after the sequence table

Sample Input

7
A B C D E F G

Sample Output

G F E D C B A

My code:
#include <stdio.h>
#include <malloc.h>
struct sqllist
{
int length;
char data;
};
void InitList(sqllist *&L)
{

L =(sqllist*)malloc(sizeof(sqllist));
L->length = 0;
}
void CreatList(sqllist *&L,int n,char a[])
{
int i;
for (i=n-1;i>=0;i--)
{
L->data[n-1-i] = a[i];

}
L->length = n;
}
void DispList(sqllist* L)
{
int i;
for (i=0;i<L->length;i++)
{
// if (i==0)
// {
// printf("%c",L->data[i]);
// }
// else
// {
// printf(" %c",L->data[i]);
// }
printf ("%c ",L->data[i]);
}
printf("\n");
}
void DestoryList(sqllist *L)
{
free(L);
}
int main()
{
int i,n;
sqllist * L;
char a;
while (scanf("%d",&n)&&n!=0)
{

getchar();
for (i=0;i<n;i++)
{
scanf(" %c",&a[i]);
}
InitList(L);
CreatList(L,n,a);
DispList(L);

}
return 0;
}

Started by Morton at February 09, 2016 - 10:20 AM

Malloc memory, does not need to release it????

Posted by Doris at February 22, 2016 - 10:35 AM

```{
int length;
char data;   //Size 50
};
.
.
.
for (i=n-1;i>=0;i--)   //The value of I is based on input n determines if the input n is 51
{
L->data[n-1-i] = a[i];  //a...
}
```

Posted by Booth at March 01, 2016 - 11:22 AM

void InitList(sqllist *&L)
This is the wording of C. . .

Posted by Kent at March 13, 2016 - 11:46 AM

This problem is not it,, I don't know what went wrong.

Posted by Morton at November 18, 2016 - 3:00 AM

You mean I'm an array of small?? But I tried seemed not ah

Posted by Morton at November 25, 2016 - 3:40 AM

We began to learn C language version of the data structure now, teach

Posted by Morton at December 04, 2016 - 4:40 AM

Have a look the input and output formats you is correct.

Posted by Ignatz at December 15, 2016 - 5:16 AM

1)Malloc memory, do not release, this is a very serious mistake
2)Reverse the order form, this kind of data structure, not the establishment of a reverse sequence table and the input data.
3)Data should be input function, input to the table, complete inversion, use the output function output (usually file input and output).
4)C can't use C++ data type
5)Table size is not fixed, the best dynamic memory allocation, data number, should also be changed dynamically

The above problems, in addition to 5) can be careless clearance
You have not been solved.
Among them
3)This topic is the standard treatment.
2)Is the core, is you have to do the task.
1)Should not be wrong, do not do is unfinished, so is required.
As for the 4)
Look for permission, with C++, and you actually use C, or C++.
Do not allow, that is a mistake, allow, can not modify, but not C, C++. must be used
C will not be able to use a reference type

Posted by Doris at December 24, 2016 - 6:12 AM

This indicates that there are some problems did not take into account the need... Guess. Test data. The feeling of feeling....
AC this kind of thing, don't be too hard on yourself. Ha ha.

Posted by Aries at December 30, 2016 - 6:56 AM

Is it to the size of the array, you need to change the program, do a cross-border judgment of input n

Posted by Booth at January 01, 2017 - 7:55 AM I did not write. Ask landlord code AC. Going crazy.

The most began to write is a single character inversion. WA.

Then the students to consider multiple characters, desperately finished. Results WA. Fucking.

How are not measured out the problem. Ha-ha. Too lazy to write. But however.

Put a code. And the landlord to share.
```#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
int n;
char **index;
char *t;
char temp;
int i;

scanf("%d", &n);
getchar();
if(n > 0)
{
index = (char **)malloc(n*sizeof(char *));
i = 0;
while(i <n)
{
scanf("%s", temp);
*(index+i) = (char *)malloc((strlen(temp)+1)*sizeof(char));
strcpy(*(index+i), temp);
i++;
}
}

i = 0;
while(i <= n/2)
{
t = *(index+i);
*(index+i) = *(index+(n-1)-i);
*(index+(n-1)-i) = t;
i++;
}

i = 0;
while(i <n-1)
{
printf("%s ", *(index+i));
i++;
}
printf("%s\n", *(index+i));
return 0;
}
```

It seems this semester I do not go the CE route, WA route. It's too boring. For example only a single character, do not explain to the multiple character operation. Fucking. Never cold for OJ, annoying very.

Posted by Webster at January 05, 2017 - 9:26 AM

The 8 floor of the very place！ Posted by Winston at January 06, 2017 - 8:28 AM

11 building program following modified AC:
1 do not have to switch input elements of the order, began to reverse the output input elements directly from the N-1
Not 2 the last data output when the enter (or format error)

It seems that the LZ program is the main problem of:
1 only consider a single character
Maximum number of 2 defined input element is 50

```#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
int n;
char **index;
char *t;
char temp;
int i;

scanf("%d", &n);
getchar();
if(n > 0)
{
index = (char **)malloc(n*sizeof(char *));
i = 0;
while(i <n)
{
scanf("%s", temp);
*(index+i) = (char *)malloc((strlen(temp)+1)*sizeof(char));
strcpy(*(index+i), temp);
i++;
}
}

/*Delete: do not have to switch input order of elements
i = 0;
while(i <= n/2)
{
t = *(index+i);
*(index+i) = *(index+(n-1)-i);
*(index+(n-1)-i) = t;
i++;
}*/

i = n-1;//I = 0;
while(i > 0)//Modification of while(i <n-1)
{
printf("%s ", *(index+i));
i--;//Modification of i++;
}
printf("%s", *(index)); //Modification of printf("%s\n", *(index+i));
return 0;
}

```

Posted by William at January 10, 2017 - 9:19 AM