OpenGL中的画线

OpenGL中的画线,第1张

开始时,默认下是采用实闹拿晌线模式的,所以前面开始是实线,后面你启用了点划模式,所以后面是点划线,OpenGL保留了这敏棚个状态,经过glutMainLoop后液锋,重画,采用的点划线的方式,所以前面的直线也是点划线了

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std

void main()

{

int n,*a

float aver

int i,j

int max,maxtimes

cout<<"n="

cin>>n

srand( (unsigned)time( NULL ) )

a=new int[n]

aver=0

for(i=0i<ni++)

{

int y=0

int cnt=0

while(y<5 &&y>-10)

{

if(rand()%2==1)

y++

else

y--

cnt++

}

a[i]=cnt

aver+=cnt

}

for(i=0i<ni++)

cout<<a[i]<<' '

cout<罩兆逗<endl

aver/=n

cout<<"a="<<aver<<endl

for(i=0i<n-1i++)

for(j=0j<n-i-1j++)

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

{

int temp=a[j]

a[j]=a[j+1]

a[j+1]=temp

}

maxtimes=0

i=0

while(i<n)

{

for(j=ia[j+1]==a[j]j++)

if(j-i+1>maxtimes)

{

maxtimes=j-i+1

max=a[j]

}

i=j+1

}

cout<<"m="<<max<<endl

}

由于算法的问题,我的程序在局数没有物卖重复数字的情况猜卜下,输出的是最小值。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8253303.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-14
下一篇2023-04-14

发表评论

登录后才能评论

评论列表(0条)

    保存