求编程大神(用记事本编程是大神吗)

2023-11-13 07:41:19 数码极客 bianji01

 

求编程大神解答(VB,C语言)

#include

#include

#include

#include

//0.4。。。5.0乘以5等于2,3,4,。。。,25,于是可以先产生2~25的随机数,

//然后检测有没有和前面的重复,如果有重复重新产生2~25的随机数,直到生成7个数

voidRand(float*array,intnum=7)

int*iArray=(int*)malloc(sizeof(int)*num);

inti,index=0;

while(index

iArray[index]=rand()%24+2;

for(i=0;i

if(iArray[index]==iArray[i])continue;

array[index]=iArray[index]*0.2f;

index++;

free(iArray);

//由于不知道平均数有多少,只能用链表结构

structtongji

floatnum;

inttimes;

structtongji*next;

//将平均数插入链表中,如果找到相同的平均数,将其times加1,

//找不到重新申请空间插到链表尾部

structtongji*addNum(structtongji*first,floatnum)

structtongji*pNow,*pNew;

if(first==NULL)

pNew=(structtongji*)malloc(sizeof(structtongji));

pNew->next=NULL;

pNew->num=num;

pNew->times=1;

returnpNew;

pNow=first;

while(pNow!=NULL)

if((pNow->num-num)*(pNow->num-num)<1E-20)

pNow->times++;

break;

pNow=pNow->next;

if(pNow==NULL)

pNew=(structtongji*)malloc(sizeof(structtongji));

pNew->next=NULL;

pNew->num=num;

pNew->times=1;

if(first==NULL)returnpNew;

pNow=first;

while(pNow->next!=NULL)pNow=pNow->next;

pNow->next=pNew;

returnfirst;

//打印最前num个数

voidprint(structtongji*first,intnum=10)

structtongji*pNow=first;

while(pNow!=NULL&&num-->0)

printf("%f%d\n",pNow->num,pNow->times);

pNow=pNow->next;

//排序,只排最大的num个

structtongji*sort(structtongji*first,intnum=10)

structtongji*pNow,*pMax,*pMaxBefore,*pNewArray=NULL,*pFirst,*pNewArrayTail;

pFirst=first;

while(pFirst!=NULL&&num-->0)

pMax=pNow=pFirst;

pMaxBefore=NULL;

while(pNow->next!=NULL)

if(pNow->next->times>pMax->times)

pMaxBefore=pNow;

pMax=pNow->next;

pNow=pNow->next;

if(pNewArray==NULL)

if(pMaxBefore)pMaxBefore->next=pMax->next;

elsepFirst=pFirst->next;

pNewArrayTail=pNewArray=pMax;

pNewArrayTail->next=NULL;

if(pMaxBefore)pMaxBefore->next=pMax->next;

elsepFirst=pFirst->next;

pNewArrayTail->next=pMax;

pNewArrayTail=pNewArrayTail->next;

pNewArrayTail->next=NULL;

if(pFirst!=NULL)pNewArrayTail->next=pFirst;

returnpNewArray;

//删除链表

voiddeleteTongji(structtongji*first)

structtongji*pNow=first;

while(pNow!=NULL)

first=pNow->next;

free(pNow);

pNow=first;

//求平均数

floataverage(float*arrary,intnum=7)

inti;

floatcount=0;

for(i=0;i

returncount/num;

#definekCalcTimes1000000

#definekTableLen7

#definekMaxNum10

voidmain()

floatarray[kTableLen];

inti;

structtongji*first=NULL;

srand(time(NULL));

for(i=0;i

Rand(array,kTableLen);

first=addNum(first,average(array,kTableLen));

first=sort(first,kMaxNum);

print(first,kMaxNum);

deleteTongji(first);

求编程大神:怎么设计c++程序使在键盘上输入任意一个字符串,输出该字符串,并统计输入的字符个数

#include

#include

usingnameSPAcestd;

intmain()

charstr[100];

cout<<"输入一个字符串"<

gets(str);

inti=0,k=0;

for(i=0;i

if(str[i]!=)

cout<<"输入的字符有"<

怎么他显示有一个错误

好吧你学的是C语言?我改下,马上就好!

#include

#include

intmain()

charstr[100];

inti=0,k=0;

printf("输入一个字符串\n");

gets(str);

for(i=0;i

if(str[i]!=)

printf("输入的字符有%d个\n",k);

求大神c++编程

急!急!c语言编程求帮助。。求大神

if (number > 90) printf ("you");else if (number > 60)...else if ()...

声明:易趣百科所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系315127732@qq.com
广告位招租
横幅广告