Chen-RUI
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    APCS 2021/01/09 - A卷 === ###### tags: `2021 觀念題` `筆試題目` ```c= int func ( int a[] , int s , int f) { int min = 0, max = s - 1 ; while ( min < max ){ int mid = (min + max) / 2; if ( f > a[mid] ){ min = mid + 1; } else if ( f < a[mid] ){ max = mid - 1; } else { return mid; } } return -1; } int main(){ int a[8] = { 2, 3, 3, 5, 8, 8, 8, 8 } ; printf("%d", func(a, 8, 8) ) ; } ``` 01. 上述輸出的答案為下列何者? + [A] 4 + [B] 5 + [C] 6 + [D] 7 --- ```c= int main(){ char c = 'a'; switch(c){ case 'a': printf("a"); case 'b': printf("b"); case 'c': printf("c"); default: printf("d"); } } ``` 02. 上述輸出的答案為下列何者? + [A] a + [B] abc + [C] ad + [D] abcd --- ```c= int level = 0; int num[6] ; for (int i = 1 ; i <= 6 ; i = i + 1 ) { if ( level == 0 ) { num[level] = i ; level = level + 1 ; } else if ( rand() % 2 == 0 ){ level = level - 1 ; printf("%d ", num[level] ) ; i = i - 1; } else { num[level] = i ; level = level + 1 ; } } while ( level ) { level = level - 1 ; printf("%d ", num[level] ) ; } ``` 03. rand() 是一個會回傳隨機整數的函數,試問下列選項何者是無法達成? + [A] 1 2 3 5 6 4 + [B] 4 6 5 3 1 2 + [C] 3 4 6 5 2 1 + [D] 6 5 4 3 2 1 --- ```c= int f(){ int a[5] = { 9, 2, 4, 7, 3 } ; int b[10] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1} ; int c = 0; for (int i = 0; i < 5 ; i = i + 1 ) { c += b[ a[i] ]; } return c; } ``` 04. 回傳的 c 值為多少? + [A] 1 + [B] 2 + [C] 3 + [D] 4 --- ```c= int f ( int n ){ if ( n < 2 ) return n ;    else return n + f(__________) ; } ``` 05. 執行上述的函數時回傳的結果: $f$(14) = 28 ,$f$(10) = 21 , $f$(6) = 12,判斷式該如何選擇才能符合對應關係? + [A] $\frac{n+1}{2}$ + [B] $\frac{n}{2}$ + [C] $\frac{n-1}{2}$ + [D] $\frac{n}{2}+1$ --- ```c= int f ( int n ){ int a[5] = { 5, 3, 10, 4, 20 } ; int b[5] = {} ; int size = 0 ; for ( int i = 0 ; i < 5; i = i + 1 ) { b[ size ] = a[i] ; size = size + 1 ; } while ( size ) { printf("%d ", b[ size - 1]); size = size - 1 ; } } ``` 06. 執行上述的函數時後輸出的結果? + [A] 3 4 5 10 20 + [B] 5 3 10 4 20 + [C] 20 10 5 4 3 + [D] 20 4 10 3 5 --- ```c= for (int i = 0; i < 6 ; i += 1 ){ for (int j = 0 ; __________ ; j += 3 ){ printf("[%d]", i+j); } } ``` 07. 執行為上述的程式碼後輸出結果為[1][2][3][4][7][5][8],試問判斷是該如何選擇? + [A] $j < i$ + [B] $j \leq i$ + [C] $j > i$ + [D] $j \geq i$ --- ```c= void reverse( int a[], int n ) { for (int i = 0 ; __________ ; i += 1 ) { int temp = a[i] ; a[i] = a[ n-1-i ] ; a[ n-1-i ] = temp ; } } ``` 08. 為了讓陣列反向儲存時,判斷式應該如何選擇? + [A] $i < n$ + [B] $i < \frac{n}{2}$ + [C] $i \leq n$ + [D] $i \leq \frac{n}{2}+1$ --- ```c= #define SIZE 7 int main() { int outer = 0 , sum = 0 , index = 0 ; int a[7] = { 2, 1, 3, 4, 5, 0, 6 } ; while( outer < SIZE ){ for( index = 0 ; index < a[outer] ; index += 1 ) if( index > 5 ) break ; else if ( a[ index ] >= a[ index + 1 ] ){ sum = sum + a[ index ] ; a[ index ] = a[ index + 1 ] ; } outer = outer + sum ; } } ``` 09. 執行完上述的程式碼後 sum 的值應該為多少? + [A] 0 + [B] 2 + [C] 3 + [D] 6 --- ```c= void f(int x, int y){ int temp = x; x = y; y = temp; } int main(){ int x = 2, y = 5 ; f(x, y) ; printf("%d", (x - y) * (x + y + 4) ); } ``` 10. 輸出數值為多少? + [A] 33 + [B] 1 + [C] -1 + [D] -33 --- ```c= int f(int *a, int *b) ; int g(int *a, int *b) ; int main(){ int a = 32, b = 5 ; int x = f(&a, &b) ; printf("%d %d %d", x, a, b) ; } int f(int *a, int *b ) { int c = 10 ; *a = *a + *b / 5 ; int p = g(b, a) % 2; if (p % 2 == 0){ return *b - p ; } else { return *b + p ; } } int g(int *a ,int *b ) { return ( *a - *b ) * 5 + 2 ; } ``` 11. 輸出數值為多少? + [A] 5 33 5 + [B] 5 32 5 + [C]143 33 5 + [D]143 32 5 --- ```c= int f(char s[], int n){ char t[1000] ; int j = 0 ; for (int i = 0 ; i < strlen(s) ; i += 1, j += 2) { if (s[ i ] == '0'){ t[ j ] = 'w' ; t[j+1] = 'a' ; } else if ( _____ || _____ ) { t[ j ] = 't' ; t[j+1] = 'e' ; } else if (s[ i ] == '3' || s[ i ] == '5'){ t[ j ] = 'd' ; t[j+1] = 'o' ; } else if (s[ i ] == '4' || s[ i ] == '6'){ t[ j ] = 'p' ; t[j+1] = 'u' ; } else { t[ j ] = ' '; j = j - 2 ; } } t[j] = '\0'; printf("%s\n", t); } int main(){ char s[] = "0328675"; f(s, 8); } ``` 12. 輸出"wadoteputedo"時,判斷式應該如何選擇才符合題目要求? 原版是給定 3 個數字字串對應的英文字串... + [A] s[i] == '2' || s[i] == '7' + [B] s[i] == '2' || s[i] == '8' + [C] s[i] == '1' || s[i] == '8' + [D] s[i] == '1' || s[i] == '2' --- ```c= int main(){ char s[] = "3*5/6+2-1" ; char a[10] = {} ; char b[10] = {} ; int la = 0, lb = 0 ; for ( int i = 0 ; i < strlen(s) ; i += 1 ){ switch( s[i] ){ case '+': case '-': case '*': case '/': a[la] = s[i] ; la = la + 1 ; break ; default : b[lb] = s[i] ; lb = lb + 1 ; } } while( la ){ la = la - 1 ; b[ lb ] = a[ la ] ; lb = lb + 1 ; } b[lb] = '\0' ; printf("%s\n",b ) ; } ``` 13. 輸出的字串為何? + [A] 35621*/+ - + [B] */+ -35621 + [C] 35621- +/* + [D] *35/9+2-1 --- ```c= int main(){ int n ; scanf("%d", &n) ; int mat[n][n] = {}; int x = n-1 , y = (n - 1) / 2 ; for(int i = 1 ; i <= n * n ; i = i + 1 ){ int a = _____ ; int b = _____ ; if ( mat[a][b] ){ a = ( x + 1 )% n; b = y ; } x = a ; y = b ; mat[x][y] = i ; } } ``` 14. 邊長N為奇數的魔方陣,依照下列規則填入1到 $N^{2}$ 的數字就能保證每一行和每一列以及斜對角的數字總和都相同。 (1) 由最下面那一列的中間格開始填入1 (2) 接續格在前一格的左下方,除非超出邊界或格內已填數字 (3) 超出下邊界,則接續格改為左邊一行的最上面一列,除非超出左邊界如說明(6) (4) 超出左邊界,則接續格改為下面一列的最右邊一行,除非超出下邊界如說明(6) (5) 若接續格已填有數字,接續格改為原格上方一格 (6) 若下面及左邊同時超出邊界時,接續格改為原格的上方一格 + [A] (x-1+n)%n , (y+1+n)%n + [B] (x-1+n)%n , (y-1+n)%n + [C] (x+1+n)%n , (y+1+n)%n + [D] (x+1+n)%n , (y-1+n)%n

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    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

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully