Case Study: Focus on Structures Math 130 Lecture 21 B Smith: 10/04: Required 35 minutes to complete. 15 minutes was spent returning test 2 and completing the surveys. Good examples here B Smith: Conisder skipping? No. There are good examples of use of structures, modulus, arrays of structures, pointers to struct. B Smith: Alex came in and discussed Mindstorms for 10 minutes, lecture took 40 to 45 min B Smith: 10/31/05: time 45 minutes. Students were quite interested and challenged. Good “thinking” exercise. Rate: 3
15
Embed
Case Study: Focus on Structures Math 130 Lecture 21 B Smith: 10/04: Required 35 minutes to complete. 15 minutes was spent returning test 2 and completing.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Case Study:Focus on Structures
Math 130
Lecture 21
B Smith:
10/04: Required 35 minutes to complete. 15 minutes was spent returning test 2 and completing the surveys. Good examples here
B Smith:
10/04: Required 35 minutes to complete. 15 minutes was spent returning test 2 and completing the surveys. Good examples here
B Smith:
Conisder skipping? No. There are good examples of use of structures, modulus, arrays of structures, pointers to struct.
B Smith:
Conisder skipping? No. There are good examples of use of structures, modulus, arrays of structures, pointers to struct.
B Smith:
Alex came in and discussed Mindstorms for 10 minutes, lecture took 40 to 45 min
B Smith:
Alex came in and discussed Mindstorms for 10 minutes, lecture took 40 to 45 min
B Smith:
10/31/05: time 45 minutes. Students were quite interested and challenged. Good “thinking” exercise. Rate: 3
B Smith:
10/31/05: time 45 minutes. Students were quite interested and challenged. Good “thinking” exercise. Rate: 3
3
Overview
• Case Study deck of cards implementation shuffling simulation dealing
4
Struct Case Study• card is the structure name and is used to declare variables of the
structure type• card contains two members of type char *
/* shuffle cards */void shuffle( Card * const wDeck ){ int i; /* counter */ int j; /* hold random value between 0 - 51 */ Card temp; /* temporary structure for swapping Cards */
/* loop through wDeck randomly swapping Cards */ for ( i = 0; i <= 51; i++ ) { j = rand() % 52; temp = wDeck[ i ]; wDeck[ i ] = wDeck[ j ]; wDeck[ j ] = temp; }}
15
void deal()
/* deal cards */void deal(Card * wDeck ){ int i; /* counter */ for ( i = 0; i <= 51; i++ ) { printf( "%5s of %-8s%c", wDeck[ i ].face, wDeck[ i ].suit, ( i + 1 ) % 2 ? '\t' : '\n' ); }}