cyg41223103 cp2023

  • Home
    • SMap
    • reveal
    • blog
  • About
  • Brython
  • w15
    • Q2
    • Q1
  • 作業內容
    • W3
    • W4
    • w5
    • w6
      • 台灣國旗
      • 日本國旗
      • 美國國旗
      • 英國國旗
      • 韓國國旗
      • 中國國旗
    • W7
    • W10
    • W13
  • ANSI C
    • c1.
    • c2.
    • c3.
    • c4.
    • c5.
    • c6.
    • c7.
    • c8.
    • c9.
    • c10.
  • C_EX
    • ex1.
    • ex2.
    • ex3.
    • ex4.
    • ex5.
    • ex6.
    • ex7.
    • ex8.
    • ex9.
    • ex10.
  • NOTE
    • ssh
c7. << Previous Next >> c9.

c8.

找出兩個數字之間的最大數字

#include <stdio.h>
#include <stdlib.h>
 
int main() {
    int fno, sno, *ptr1 = &fno, *ptr2 = &sno;
 
    printf("\n\n Pointer : Find the maximum number between two numbers :\n");
    printf("------------------------------------------------------------\n");
 
    printf(" Input the first number : ");
    scanf("%d", ptr1); // 讀取使用者的第一個數字並使用 ptr1 儲存它
    printf(" Input the second number : ");
    scanf("%d", ptr2); // 從用戶那裡讀取第二個數字並使用 ptr2 儲存它
 
    // 比較ptr1和ptr2指向的值,找出最大數
    if (*ptr1 > *ptr2) {
        printf("\n\n %d is the maximum number.\n\n", *ptr1); // 列印最大數量
    } else {
        printf("\n\n %d is the maximum number.\n\n", *ptr2); //列印最大數量
    }
    return 0;
}


c7. << Previous Next >> c9.

Copyright © All rights reserved | This template is made with by Colorlib