# 1B-9 ###### tags: `一上程設` ### 程設1b-9 eg1 ``` #include <stdio.h> void showRectangle(int,int); int main(void) { int width, height; printf("Enter the size of the rectangle > "); scanf("%d%d", &height, &width); showRectangle(height, width); return 0; } void showRectangle(int h, int w) { int i, j; for(i = 1; i <= h; i++) { for(j = 1; j <= w; j++) printf(" *"); printf("\n"); } } ``` ### 程設1b-9 eg2 1st ``` #include <stdio.h> #include <stdlib.h> #include <time.h> void showSomePRN(int); int main(void) { printf("Show 10 pseudorandom numbers:\n"); srand(time(NULL)); showSomePRN(10); return 0; } void showSomePRN(int n) { int i; for(i = 0; i < n; i++) printf("%d\t", rand() % 20); } ``` ### 程設1b-9 eg2 2nd ``` #include <stdio.h> #include <stdlib.h> #include <time.h> int showOnePRN(int); int main(void) { int i; printf("Show 10 pseudorandom numbers:\n"); srand(time(NULL)); for(i = 0; i < 10; i++) printf("%d ", showOnePRN(20)); return 0; } int showOnePRN(int n) { return rand() % n; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up