zoukankan      html  css  js  c++  java
  • [YTU]_2738 指针练习--变量交换

    Description

    注:本题只需要提交填写部分的代码

    用指针变量对两个整数按从小到大排序。

    /*C++*/

    #include <iostream>
    using namespace std;
    int main()
    {
        int *p1,*p2,*p;
        int a,b;
        cin>>a>>b;
        p1=&a;
        p2=&b;
        if(a>b)
        {
        /*******************************
         请在该部分补充缺少的代码
        ********************************/

        }
        cout<<"min:"<<*p1<<endl;
        cout<<"max:"<<*p2<<endl;
        return 0;
    }

    /*C*/

    #include<stdio.h>
    int main()
    {
        int *p1,*p2,*p;
        int a,b;
        scanf("%d%d",&a,&b);
        p1=&a;
        p2=&b;
        if(a>b)
        {
        /*******************************
         请在该部分补充缺少的代码
        ********************************/

        }
        printf("min:%d ",*p1);
        printf("max:%d ",*p2);
        return 0;
    }

    Input

    两个整数

    Output

    按从小到大输出两个整数

    Sample Input

    2 1

    Sample Output

    min:1
    max:2
    #include <iostream>
    using namespace std;
    int main()
    {
        int *p1,*p2,*p;
        int a,b;
        cin>>a>>b;
        p1=&a;
        p2=&b;
        if(a>b)
        {
        p=p1;
        p1=p2;
        p2=p;
        }
        cout<<"min:"<<*p1<<endl;
        cout<<"max:"<<*p2<<endl;
        return 0;
    }

  • 相关阅读:
    二分制--找最小值去重
    angular过滤 排序问题
    div+css背景渐变色代码
    angular中对象与字符串之间的转换
    AMD模块
    jquery.validate
    谈谈js中深度克隆和浅度克隆
    还在使用git吗?不妨来看看如何使用git管理版本
    闭包
    js复习
  • 原文地址:https://www.cnblogs.com/sxy201658506207/p/7586397.html
Copyright © 2011-2022 走看看