My new problem:
Ok, I think I am doing this right. How do I get it to print the new array after I have changed the element to the guest initial?
EDIT: Also I know that I am probably not doing this the best way possible, but I have to do it the way I know how, I want to understand what I am doing, and this is just the way I work it out.
This is what I have:
Code:#include <stdio.h> #define ROWS 4 #define COLUMNS 2 #include <stdio.h> void printArray(int a[][2]); void modifyElement(int e, char guest); int main() { int table[ROWS][COLUMNS]={1,2,3,4,5,6,7,8}; int seat; int r; int c; char guest, junkChar; printArray(table); getchar(); printf("In which seat would you like to place a guest?\n"); scanf("%d",&seat); scanf("%c",&junkChar); printf("What is the initial of the guest you would like to place in this seat?\n"); scanf("%c",&guest); switch(seat){ case 1: r=0;c=0; break; case 2: r=0;c=1; break; case 3: r=1;c=0; break; case 4: r=1;c=1; break; case 5: r=2;c=0; break; case 6: r=2;c=1; break; case 7: r=3;c=0; break; case 8: r=3;c=1; break; default: printf("You have entered an invalid seat number, please restart program.\n"); return 0; break; } modifyElement(table[r][c],guest); return 0; } void printArray(int a[][2]) { int i; int j; printf("\t_____U____\n"); for(i=0;i<=3;i++) { for(j=0;j<=1;j+=2){ printf("\t%d|\t|%d\n",a[i][j],a[i][j+1]); } } printf(" \t----------\n"); } void modifyElement(int e, char guest) { e = guest; }
ORIGINAL POST (already figured out):
How would I write a function to print an array that looks like this:
__U__
1| |2
3| |4
5| |6
7|___|8
I am able to get the array, but dont know how to get the lines.
Thanks in advance for any input.
EDIT: Its actually supposed to look like a rectangular table with columns 1,3,5,7 and 2,4,6,8. I dont know why I cant make it look right in this post.



LinkBack URL
About LinkBacks


