fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int a, b, temp;
  5. int *p1, *p2;
  6. printf("請輸入 a 的值:");
  7. scanf("%d", &a);
  8. printf("請輸入 b 的值:");
  9. scanf("%d", &b);
  10.  
  11. p1 = &a;
  12. p2 = &b;
  13.  
  14. if(*p1 < *p2){
  15. temp = *p1;
  16. *p1 = *p2;
  17. *p2 = temp;
  18. }
  19. printf("*p1的值:%d\n", *p1);
  20. printf("*p2的值:%d\n", *p2);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 9424KB
stdin
3;7
stdout
請輸入 a 的值:請輸入 b 的值:*p1的值:3
*p2的值:0