jdtt 2020-05-16 19:26 采纳率: 66.7%
浏览 154

noj检测位图长宽。绝望了啊啊啊啊

啊绝望了,求各位大佬看一下我的代码

PS:我知道可能会有各种问题,但题目给出的网站显示“页面不存在”啊啊啊!

图片说明

图片说明

截图可能有点重复,但不影响各位大佬的阅读!下面是我的代码:

感谢各位!!!

#include <iostream>
#include <fstream>
using namespace std;

struct FILE_HEADER{
    unsigned short bfType[2];
    unsigned int bfSize;
    unsigned short bfReserved1; 
    unsigned short bfReserved2; 
    unsigned int bfOffBits;
};

struct INFORMATION_HEADER{
    unsigned int biSize;
    int biWidth;
    int biHeight;
    unsigned short biPlanes;
    unsigned short biBitCount;
    unsigned int biCompression;
    unsigned int biSizeImage;
    int biXPelsPerMeter;
    int biYPelsPerMeter;
    unsigned int biClrUsed; 
    unsigned int biClrImportant;
};

int main(){
    FILE_HEADER h1;
    INFORMATION_HEADER h2;
    ifstream inf("DATA5611.BMP",ios::binary);
    if(!inf){
        cerr<<"open error!"<<endl;
        abort();
    }
    inf.seekg(ios::beg);
    inf.read((char *)&h1,sizeof(h1));
    inf.seekg(sizeof(h1),ios::beg);
    inf.read((char *)&h2,sizeof(h2));
    cout<<h2.biWidth<<" "<<h2.biHeight<<endl;
    inf.close();
}
  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2020-09-23 13:44
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据