博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[ZhuJei]C++实验2.1/2.2
阅读量:3575 次
发布时间:2019-05-20

本文共 1570 字,大约阅读时间需要 5 分钟。

实验内容:

//zhangguizhu 是个好老师!
题目2.1 利用位运算将一个128位的数扩大两倍

内容:利用位运算将一个128位的数扩大两倍。例如:输入:4 12 9 5 输出:00000000000000000000000000001010 00000000000000000000000000010010 00000000000000000000000000011000 00000000000000000000000000001000 题目2.2 :输入一个十进制数int或float类型,利用位操作,输出机内表示的二进制数.内容:输入一个十进制数int或float类型,利用位操作,输出机内表示的二进制数.例如:输入:8    输出:00000000000000000000000000001000 要求运行结果是给出的程序运行结果截图,并且至少给出三组不同类型的数据测试用例。
#pragma comment(linker, "/STACK:1024000000,1024000000")#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f#define EPS 1e-24using namespace std;//实验2.1,2.2/*Tips:需要注意数字溢出,128位的有符号数用四个有符号int表示会有问题 *要用无符号的int,或者用ll 目前的疑惑 *计算机内不是从低位子节在前,高位子节在后 *不是所有整数都可以用float表示,看似一样的两个数用int/float计算机内部表示不一定相同 *模仿java的floatBitsToInt(),我们可以强制指针类型的转换来求 *测试数据:34 12 9 54294967295 2147483647 5 62147483647 5 6 42949672953812799994125.52.330.1251024.2 */typedef long long ll;const ll Mod = 1e9 + 7;//输出二进制数void print_binary(int x){ for(int i=31;i>=0;i--){ cout<< ((x&(1<
=0;i--){ cout<< ((x&(1<
> T; while(T--){ cin>>a>>b>>c>>d; int flag_a = check(a),flag_b = check(b),flag_c = check(c),flag_d = check(d); a <<= 1;b <<= 1;c <<= 1;d <<= 1;//cout<
<
<
<
<
> T; int num; while(T--){ cin>>num; print_binary(num); cout<
> T; float num; while(T--){ cin>>num; int *numD = (int *)# print_binary(*numD); //char *p = (char *) # //print_binary(*numD); /*print_binary2(*p); print_binary2(*(p+1)); print_binary2(*(p+2)); print_binary2(*(p+3));*/ cout<

转载地址:http://ykjgj.baihongyu.com/

你可能感兴趣的文章
C/C++之struct的小知识
查看>>
温湿度传感器(AM2312)
查看>>
centos下显卡驱动和cuda安装
查看>>
iris练习
查看>>
线性回归
查看>>
方差的意义
查看>>
关于知云文献翻译显示乱码,无法翻译的解决方法
查看>>
matlab fopen与fprintf操作(读、写文件操作)
查看>>
matlab fscanf
查看>>
matlab plot
查看>>
plot(2)
查看>>
matlab subplot
查看>>
matlab直方图,饼图
查看>>
matlab 图像保存方法
查看>>
matlab 图像操作
查看>>
直方图均衡化
查看>>
opencv 批量读取图片、处理,并批量保存
查看>>
matlab 图像处理
查看>>
利用python做一个简易计算器
查看>>
matlab Gui set get
查看>>