资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

coutvb.net的简单介绍

WINDOWS的一般程序是用什么语言编写的?

可以肯定的说基本上都是c和c++语言。。。。你说c++语言没有界面是你的概念理解错误,语言本身都是不提供所谓“界面”的,提供界面的是某些函数库或者类库,比如win32api函数或者mfc,qt的库,就像标准库会提供cin和cout一样。你只用了标准库,当然没界面了。另外千千静听绝不会是c#写的,因为从没见过运行个千千还需要framework支持的(莫非我的版本老了??)

为晋中等地区用户提供了全套网页设计制作服务,及晋中网站建设行业解决方案。主营业务为成都网站设计、网站制作、晋中网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

C++读取BMP图像

#includemath.h

#include iomanip.h

#include stdlib.h

#include windows.h

#include stdio.h

#include stdlib.h

#include iostream.h

#include fstream.h

//---------------------------------------------------------------------------------------

//以下该模块是完成BMP图像(彩色图像是24bit RGB各8bit)的像素获取,并存在文件名为xiang_su_zhi.txt中

unsigned char *pBmpBuf;//读入图像数据的指针

int bmpWidth;//图像的宽

int bmpHeight;//图像的高

RGBQUAD *pColorTable;//颜色表指针

int biBitCount;//图像类型,每像素位数

//-------------------------------------------------------------------------------------------

//读图像的位图数据、宽、高、颜色表及每像素位数等数据进内存,存放在相应的全局变量中

bool readBmp(char *bmpName)

{

FILE *fp=fopen(bmpName,"rb");//二进制读方式打开指定的图像文件

if(fp==0) return 0;

//跳过位图文件头结构BITMAPFILEHEADER

fseek(fp, sizeof(BITMAPFILEHEADER),0);

//定义位图信息头结构变量,读取位图信息头进内存,存放在变量head中

BITMAPINFOHEADER head;

fread(head, sizeof(BITMAPINFOHEADER), 1,fp); //获取图像宽、高、每像素所占位数等信息

bmpWidth = head.biWidth;

bmpHeight = head.biHeight;

biBitCount = head.biBitCount;//定义变量,计算图像每行像素所占的字节数(必须是4的倍数)

int lineByte=(bmpWidth * biBitCount/8+3)/4*4;//灰度图像有颜色表,且颜色表表项为256

if(biBitCount==8)

{

//申请颜色表所需要的空间,读颜色表进内存

pColorTable=new RGBQUAD[256];

fread(pColorTable,sizeof(RGBQUAD),256,fp);

}

//申请位图数据所需要的空间,读位图数据进内存

pBmpBuf=new unsigned char[lineByte * bmpHeight];

fread(pBmpBuf,1,lineByte * bmpHeight,fp);

fclose(fp);//关闭文件

return 1;//读取文件成功

}

//-----------------------------------------------------------------------------------------

//给定一个图像位图数据、宽、高、颜色表指针及每像素所占的位数等信息,将其写到指定文件中

bool saveBmp(char *bmpName, unsigned char *imgBuf, int width, int height,

int biBitCount, RGBQUAD *pColorTable)

{

//如果位图数据指针为0,则没有数据传入,函数返回

if(!imgBuf)

return 0;

//颜色表大小,以字节为单位,灰度图像颜色表为1024字节,彩色图像颜色表大小为0

int colorTablesize=0;

if(biBitCount==8)

colorTablesize=1024;

//待存储图像数据每行字节数为4的倍数

int lineByte=(width * biBitCount/8+3)/4*4;

//以二进制写的方式打开文件

FILE *fp=fopen(bmpName,"wb");

if(fp==0) return 0;

//申请位图文件头结构变量,填写文件头信息

BITMAPFILEHEADER fileHead;

fileHead.bfType = 0x4D42;//bmp类型

//bfSize是图像文件4个组成部分之和

fileHead.bfSize= sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)

+ colorTablesize + lineByte*height;

fileHead.bfReserved1 = 0;

fileHead.bfReserved2 = 0;

//bfOffBits是图像文件前3个部分所需空间之和

fileHead.bfOffBits=54+colorTablesize;

//写文件头进文件

fwrite(fileHead, sizeof(BITMAPFILEHEADER),1, fp);

//申请位图信息头结构变量,填写信息头信息

BITMAPINFOHEADER head;

head.biBitCount=biBitCount;

head.biClrImportant=0;

head.biClrUsed=0;

head.biCompression=0;

head.biHeight=height;

head.biPlanes=1;

head.biSize=40;

head.biSizeImage=lineByte*height;

head.biWidth=width;

head.biXPelsPerMeter=0;

head.biYPelsPerMeter=0;

//写位图信息头进内存

fwrite(head, sizeof(BITMAPINFOHEADER),1, fp);

//如果灰度图像,有颜色表,写入文件

if(biBitCount==8)

fwrite(pColorTable, sizeof(RGBQUAD),256, fp);

//写位图数据进文件

fwrite(imgBuf, height*lineByte, 1, fp);

//关闭文件

fclose(fp);

return 1;

}

//----------------------------------------------------------------------------------------

//以下为像素的读取函数

void xiang_su_du_qu()

{

//读入指定BMP文件进内存

char readPath[]="nv.BMP";

readBmp(readPath);

//输出图像的信息

cout"width="bmpWidth" height="bmpHeight" biBitCount="biBitCountendl;

//循环变量,图像的坐标

//每行字节数

int lineByte=(bmpWidth*biBitCount/8+3)/4*4;

//循环变量,针对彩色图像,遍历每像素的三个分量

int m=0,n=0,count_xiang_su=0;

//将图像左下角1/4部分置成黑色

ofstream outfile("图像像素.txt",ios::in|ios::trunc);

if(biBitCount==8) //对于灰度图像

{

//------------------------------------------------------------------------------------

//以下完成图像的分割成8*8小单元,并把像素值存储到指定文本中。由于BMP图像的像素数据是从

//左下角:由左往右,由上往下逐行扫描的

int L1=0;

int hang=63;

int lie=0;

//int L2=0;

//int fen_ge=8;

for(int fen_ge_hang=0;fen_ge_hang8;fen_ge_hang++)//64*64矩阵行循环

{

for(int fen_ge_lie=0;fen_ge_lie8;fen_ge_lie++)//64*64列矩阵循环

{

//--------------------------------------------

for(L1=hang;L1hang-8;L1--)//8*8矩阵行

{

for(int L2=lie;L2lie+8;L2++)//8*8矩阵列

{

m=*(pBmpBuf+L1*lineByte+L2);

outfilem" ";

count_xiang_su++;

if(count_xiang_su%8==0)//每8*8矩阵读入文本文件

{

outfileendl;

}

}

}

//---------------------------------------------

hang=63-fen_ge_hang*8;//64*64矩阵行变换

lie+=8;//64*64矩阵列变换

//该一行(64)由8个8*8矩阵的行组成

}

hang-=8;//64*64矩阵的列变换

lie=0;//64*64juzhen

}

}

//double xiang_su[2048];

//ofstream outfile("xiang_su_zhi.txt",ios::in|ios::trunc);

if(!outfile)

{

cout"open error!"endl;

exit(1);

}

else if(biBitCount==24){//彩色图像

for(int i=0;ibmpHeight;i++)

{

for(int j=0;jbmpWidth;j++)

{

for(int k=0;k3;k++)//每像素RGB三个分量分别置0才变成黑色

{

//*(pBmpBuf+i*lineByte+j*3+k)-=40;

m=*(pBmpBuf+i*lineByte+j*3+k);

outfilem" ";

count_xiang_su++;

if(count_xiang_su%8==0)

{

outfileendl;

}

//n++;

}

n++;

}

}

cout"总的像素个素为:"nendl;

cout"----------------------------------------------------"endl;

}

//将图像数据存盘

char writePath[]="nvcpy.BMP";//图片处理后再存储

saveBmp(writePath, pBmpBuf, bmpWidth, bmpHeight, biBitCount, pColorTable);

//清除缓冲区,pBmpBuf和pColorTable是全局变量,在文件读入时申请的空间

delete []pBmpBuf;

if(biBitCount==8)

delete []pColorTable;

}

void main()

{

xiang_su_du_qu();

}

在vb.net中,使用TabCoutrol,如何在打开标签的时候textbox3得到焦点?

Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged

If TabControl1.SelectedIndex = 1 Then TextBox3.Focus() '如果选项卡的索引为1,那么文本框3获得焦点

End Sub

n重循环问题: 怎样写一个n重的循环?n是输入的值。语言不限,(最好是C\c++ 、vb.net 或c#的)

谁告诉你这种问题要用n重循环来写了…………………………

要是n=10000,你还不把电脑憋炸了…………………………

编程的时候要尽量减少循环的层数,5以内没关系,但要是你打算弄个n层的循环,那就扯死了……

顺便一说,没有这种写法。

不过就你说的这个问题而言,不是n重,而是2重……无非多设一个“已经选过的数字”的数组,查一下就好了。

for n次循环输出n个数

for 从1到9

if 还没输出过 输出并添加至已输出数组

else 跳过去

这是两重循环,可不是n重循环……不要想n重循环……

vb编程计算某年某月某日是星期几

VB内置的Weekday函数就可以返回星期.

Weekday(date[, firstdayofweek])

-- date: 必要; Date类型; 要求的日期

-- firstdayofweek: 可选; vbDayOfWeek类型; 定义每周第一天(默认为星期天)

Weekday返回一个Integer, 代表每周第几天.

============================================

WeekdayName(weekday[, abbreviate][, firstdayofweek])

-- weekday: 必要; Long类型; 每周第几天

-- abbreviate: 可选; Boolean类型; 表示星期的名称是否被缩写(默认为False)

-- firstdayofweek: 可选; vbDayOfWeek类型; 定义每周第一天(默认为星期天)

WeekdayName返回一个String, 如"星期一", 但根据不同的系统, 也会返回如"Monday".

============================================

你也可以不用WeekdayName自己得到星期名

Choose(Weekday(#8/8/2008#, vbMonday), "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日")

3. 用任意一种编程语言(C/C++/Java/C#/VB.NET)写出任意一种你所知的排序算法(比如:冒泡排序, 归并排

#includestdio.h

#includestdlib.h

void BubbleSort(int a[], const int first, const int last);//冒泡排序

void InsertSort(int a[], const int first, const int last);//插入排序

void SelectSort(int a[], const int first, const int last);//选择排序

void MergeSort(int a[], const int p, const int r);//合并排序

void QuickSort(int a[],const int p,const int r);//快速排序

void ShellSort(int a[],const int p,const int r,const int dlta[],const int t);//希尔排序

void HeapSort(int a[],const int p, int r); //堆排序

void StoogeSort(int a[],const int p,const int r);//Stooge排序(不用)算法复杂度没算清楚

void main()

{

//插入排序算法

int a[11] = {6,4,5,3,2,1};

int dlta[]={9,5,3,2,1};

//BubbleSort(a,0,5);

//InsertSort(a,0,5);

//SelectSort(a,0,5);

//MergeSort(a,0,5);

//QuickSort(a,0,5);

//ShellSort(a,0,5,dlta,5);

HeapSort(a,0,5);

//StoogeSort(a,0,5);

for(int i=0; i=5;i++)

{

printf("%d ",a[i]);

}

}

/************************冒泡排序***********************/

void BubbleSort(int a[], int first, int last)

{

//实现对数组a[]中a[first]到a[last]升序的“冒泡”排序

int i,j,temp;

for(i=first; i=last; i++)

{

for(j=first; j last-i; j++)

{

if(a[j] a[j+1])

{

temp = a[j];

a[j] = a[j+1];

a[j+1] = temp;

}

}

}

}

/************************插入排序***********************/

void InsertSort(int a[], int first, int last)

{

//实现对数组a[]中a[first]到a[last]升序的“插入”排序

//最坏情况为n的平方,,多用于小数组

int i,j,temp;

for(i=first+1; i=last; i++)

{

temp = a[i];

j = i - 1;

while((j = 0) (a[j] temp))

{

a[j+1] = a[j];

j--;

}

a[j+1] = temp;

}

}

/************************选择排序***********************/

void SelectSort(int a[], int first, int last)

{

//实现对数组a[]中a[first]到a[last]升序的“选择”排序

int i, j, temp, num;

for(i=first; ilast; i++)

{

num = i;

for(j=i+1; j=last; j++)

{

if(a[j] a[num])

{

num = j;

}

}

if(i != num)

{

temp = a[num];

a[num] = a[i];

a[i] = temp;

}

}

}

/************************合并排序***********************/

void Merge(int a[],const int p,const int q,const int r)

{

//合并排序算法中的实现合并的子程序

int iLLength,iRLength;

int *L, *R, i, j, k;

iLLength = q - p + 1;

iRLength = r - q;

L = (int *)malloc(iLLength*sizeof(int)); //或者 C++中 new int[iLLength];

R = (int *)malloc(iRLength*sizeof(int)); //或者 C++中 new int[iRLength];

if(L == 0 || R== 0)

{

printf("内存分配失败!!!");

return;

}

for(i=0; iiLLength; i++)

{

L[i] = a[p+i];

}

for(j=0; jiRLength; j++)

{

R[j] = a[q+j+1];

}

i = 0;

j = 0;

for(k=p; k=r; k++)

{

if((iiLLength) (jiRLength) (L[i]=R[j]) || (j == iRLength))

{

a[k] = L[i];

i++;

}

else if(jiRLength)

{

a[k] = R[j];

j++;

}

}

free(R);free(L);

}

void MergeSort(int a[],const int p,const int r)

{

//合并排序算法-主程序

//n*lg(n),系数较小

int q;

if(pr)

{

q = (p+r)/2;

MergeSort(a,p,q);

MergeSort(a,q+1,r);

Merge(a,p,q,r);

}

}

/************************Stooge排序***********************/

void StoogeSort(int a[],const int p,const int r)

{

//Stooge算法

int temp, k;

if(a[p]a[r])

{

temp = a[p];

a[p] = a[r];

a[r] = temp;

}

if((p+1) = r)

{

return;

}

k = (r-p+1)/3;

StoogeSort(a,p,r-k);

StoogeSort(a,p+k,r);

StoogeSort(a,p,r-k);

}

/************************快速排序*********************/

int QuickPartition(int a[],const int p,const int r)

{

//快速排序的(关键)分治过程

int temp, x, i, j;

x = a[r];

i = p - 1;

for(j=p; jr; j++)

{

if(a[j] = x)

{

i = i + 1;

temp = a[i];

a[i] = a[j];

a[j] = temp;

}

}

temp = a[i+1];

a[i+1] = a[r];

a[r] = temp;

return (i+1);

}

/*

void QuickSort(int a[],const int p,const int r)

{

//快速排序算法-主程序

//与下面的“尾递归实现方法”比较,缺点:右边数组的递归不是必须的,增加了运行堆栈深度和调用开销

int q;

if(p r)

{

q = QuickPartition(a, p, r);

QuickSort(a, p, q-1);

QuickSort(a, q+1, r);

}

}

*/

void QuickSort(int a[],int p,const int r)

{

//快速排序算法-主程序

//“尾递归实现方法”是对上面的快速排序主程序实现的一种优化

//系数较小,常用大数组

int q;

while(p r)

{

q = QuickPartition(a, p, r);

QuickSort(a, p, q-1);

p = q + 1;

}

}

/************************希尔排序**********************/

void ShellInsert(int a[],const int p,const int r, int dk)

{

//希尔排序算法的关键子程序-插入排序子程序

int i, j, temp;

for(i=p+dk; i=r; i++)

{

if(a[i] a[i-dk])

{

temp = a[i];

for(j=i-dk; ((j=0) (temp a[j])); j -= dk)

{

a[j+dk] = a[j];

}

a[j+dk] = temp;

}

}

}

void ShellSort(int a[],const int p,const int r,const int dlta[],const int t)

{

//希尔排序算法-主程序

//按增量序列dlta[]中的前t个增量,实现对数组a[]中a[p]到a[r]的排序

//dlta[]可能取值如:1,2,3,5,9 dala[k]=2^(t-k+1)-1 其中0=k=t=ld(b-1)

//增量序列的最后一个值必须是1

//增量序列中的值没有除1以外的因子, 其精确时间复杂度:数学上尚未解决的难题

int k;

for(k=0; kt; k++)

{

ShellInsert(a,p,r,dlta[k]);

}

}

/************************堆排序***********************/

//堆排序,不如快速排序

//但是可用其来实现“优先级队列”

int Parent(int i)

{

return ((i+1)/2-1);

}

int Right(int i)

{

return (2*(i+1)-1);

}

int Left(int i)

{

return (2*(i+1));

}

void Max_Heapify(int a[],const int hplast,const int i)

{

int l, r,largest,temp;

l = Left(i);

r = Right(i);

largest = ((l=hplast) (a[l]a[i])) ? l:i;

if((r=hplast) (a[r]a[largest]))

{

largest = r;

}

if(largest != i)

{

temp = a[i];

a[i] = a[largest];

a[largest] = temp;

Max_Heapify(a,hplast,largest);

}

}

void Build_Max_Heap(int a[],const int p, const int r)

{

int i;

for(i = (p+r)/2; i=p; i--)

{

Max_Heapify(a,r,i);

}

}

void HeapSort(int a[],const int p, int r)

{

int i,temp;

Build_Max_Heap(a,p,r);

for(i = r; i p; i--)

{

temp = a[p];

a[p] = a[i];

a[i] = temp;

r -= 1;

Max_Heapify(a,r,0);

}

}


当前名称:coutvb.net的简单介绍
标题路径:http://cdkjz.cn/article/hhihjj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220