初学指针(输入两个整数,由大到小输出)
2017-12-08 09:32
169 查看
#include <iostream> using namespace std; int main() { void Swap(int *p1,int *p2); int a,b; cout<<"please enter a and b"<<endl; cin>>a>>b; int *pointer_1=&a,*pointer_2=&b; if(a<b) Swap(pointer_1,pointer_2); cout<<a<<b<<endl;// cout<<"a="<<" "<<a<<endl<<"b="<<" "<<b<<endl; return 0; } void Swap(int *p1,int *p2) { int tmp=*p1; *p1=*p2; *p2=tmp; }
相关文章推荐
- 用指针类型的数据作函数参数,对输入的两个整数按大小顺序输出
- 28.整数的二进制表示中1的个数 题目:输入一个整数,求该整数的二进制表达中有多少个1。 例如输入10,由于其二进制表示为1010,有两个1,因此输出2。
- Problem A: 输入两个整数,进行四则运算并输出结果
- 编程珠玑: 12章 取样问题 12.3设计空间,程序的输入包含两个整数m和n,其中m<n。输出是0~n-1范围内m个随机整数的有序列表,不允许重复。 解法2-------解题总结
- 输入a和b两个整数,按先大后小的顺序输出a和b
- Linux_C练习:输入一个整数a,再输入两个整数,输出该整数的二进制表示方法中从右端开始给定位;
- 利用指针实现将5个整数输入到数组a中,然后将a逆序复制到数组b中,并输出b中各单元的值。
- 输入一个整数a,再输入两个整数p(p<32),v(0|1),将该整数a的p位设置为v,输出修改后的该整数的二进制表示.
- 4.输入一个整数a,再输入两个整数p(p<32),v(0|1),将该整数a的p位设置为v,输出修改后的该整数的二进制表示.
- 例 8.23 输入两个整数,然后让用户选择1或2,选1时调用max函数,输出二者中的大数,选2时调用min函数,输出二者中的小数。
- 例8.2 输入a和b两个整数,按先大后小的顺序输出a和b。
- 用带参数的宏交换两个参数的值,在程序中输入两个整数并将它们交换,然后输出交换后的值
- 输入3个整数,按由小到大的顺序输出(使用指针)
- 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head。(注意,输出结果中请不要返回参数中的节点引用,否则判题程序
- 输入一个整数a,再输入两个整数p1,p2(p1,p2<32),输出该整数的二进制表示方法中从右端开始的p1到p2位.
- 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head。(注意,输出结果中请不要返回参数中的节点引用,否则判题程序
- 4.编程实现: 两个int(32位)整数m和n的二进制表达中,有多少个位(bit)不同? 输入例子: 1999 2299 输出例子:7
- 面试题:写一个java应用程序,从键盘输入两个整数,然后输出它们的平方值及立方值
- 21.输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head。(注意,输出结果中请不要返回参数中的节点引用,否则判
- 用指针处理输入3个整数,按由小到大的顺序输出