zoukankan      html  css  js  c++  java
  • c程序指针题

    题目一:

    #include<stdio.h>
    void temp(int x,int y){
    
     int temp;
     temp = x;
     x = y;
     y = tmp;
     
     printf("temp函数打印:x=%d,y=%d
    ",x,y);
    }
    
    void main(void){
    
     int a = 10 , b = 20;
     tmpx(a,b);
     printf("main函数打印:a=%d,b=%d
    ",a,b);
    
    }

     输出结果:

     x = 20 , b = 10;

       a = 10 , b = 20;

    题目二:

    #include<stdio.h>
    void temp(int *x,int *y){
     
     int temp = *x;
     *x = *y;
     *y = temp;
     
     printf("temp函数打印:*x=%d,*y=%d
    ",*x,*y);
    
    }
    void main(void){
    
     int a = 10,b = 20;
     temp(&a,&b);
     printf("main函数打印:a=%d,b=%d
    ",a,b);
    
    }

     输出结果:

     *x = 20 , *b = 10;

       a = 20 , b = 10;

     题目三:

    #include<stdio.h>
    void temp(int &x,int &y){
    
     int temp = x;
     x = y;
     y = temp;
     printf("temp函数打印:x=%d,y=%d
    ",x,y);
    }
    
    void main(void){
    
     int a = 10,b = 20;
     temp(a,b);
     printf("main函数打印:a=%d,b=%d
    ",a,b);
    
    }

     输出结果:

     x = 20 , b = 10;

       a = 20 , b = 10;

     

  • 相关阅读:
    jdbc基础
    JavaScrip练习
    EL标签
    javaBean和mvc思想
    jsp
    Session
    Cookie
    ServletConfig
    c++、opencv、泊松融合
    目标检测、Iou、nms、soft_nms、
  • 原文地址:https://www.cnblogs.com/NigelX/p/6548468.html
Copyright © 2011-2022 走看看