# Thread: Printing out a data table in different sequences

1. ## Printing out a data table in different sequences

Hi -

I am a beginning C student. My question is. I would like to print out seven different tables that are 7 x 7 using a "specific" list of 7 characters of A B C D E F G.

I will sketch out what the first table will look like and then explain what the other tables will look like as well; it is a definite simple pattern I am looking to achieve.

1 2 3 4 5 6 7

A B C D E F G
G A B C D E F
F G A B C D E
E F G A B C D
D E F G A B C
C D E F G A B
B C D E F G A

Notice how the letter A appears in the first horizontal row in position 1. Then in the row below it, "A" appears in position 2. Below this "A" is in position 3, ect. I want to be able to line up the "A"'s in a diagnal line from left to right.

... Then I want to do the SAME thing, only this time starting with the next character in the sequence of A-G ; this time it is B.

B C D E F G A
A B C D E F G
G A B C D E F
F G A B C D E
E F G A B C D
D E F G A B C
C D E F G A B

Ultimately I want to print out seven(7) different tables for each letter of: A, B, C, D, E, F, G .

I would like to have this as a switch statement to choose each letter in the character set A-G. I know that I can just use printf() to do this but I am curious as to what the code would look like to use a "specific" list of characters that would take in the first character, build the first row, then build other rows using a different sequence.

Thank you for taking my question and I hope you are having a great week .

Best Regards,

Brian

2. Here it is... took about 15 darn minutes to figure out..
as far as I know, you don't need a switch statement for this.

The thing that I wrote also works with any number of letters..
try changing myletters[] to "MOONWALKER"
Code:
```#include <stdio.h>
#include <string.h>

int main()
{
char myletters[] = "ABCDEFG";
unsigned int i, j, k, last;

for (i = 0; i < strlen(myletters); i++)
{
last = i;

for (j = i; j < strlen(myletters) + i; j++)
{
for (k = last; k < last + strlen(myletters); k++)
{
printf("%c", myletters[k % strlen(myletters)]);

}
printf("\n");
last += strlen(myletters) -1;
}
printf("\n\n");
}

return 0;
}```
Good luck

3. took me like 20-25, but mine was only good for one string.

Code:
```int thingy(char string[]) {
char *backup = malloc( strlen(string) + 1 );
strcpy(backup, string);
char *start = &string[6];
int count = 2;

printf("%s\n", string);

while(count < 8) {
backup[(8-count)] = '\0';
printf("%s%s\n", start, backup);

++count;
--start;
}

free(backup);

return 0;
}```
ill check your out more later, sleepy now...