百韵网 >>  正文

高分悬赏求一C++程序,急急急急急急急急急急急急 TSP 遗传算法 C++的程序,急找,高分悬赏

来源:www.baiyundou.net   日期:较早时间
#include<iostream.h>
#include <string.h>

const int maxsize=100;
typedef char datatype;
typedef struct node *pointer; //二叉链表类型
struct node{
datatype data;
pointer lchild, rchild;
};
typedef pointer bitree;

typedef struct{
pointer data[maxsize];
int front,rear;
}sqqueue;

pointer Q[maxsize+1]; //按层次序列建立二叉树,返回根指针
bitree level_creat(){
datatype ch;
int front,rear;
pointer root,s;
root=NULL;
front=rear=0;
while(cin>>ch,ch!='#'){
if(ch!='@'){
s=new node;
s->data=ch;
s->lchild=s->rchild=NULL;
}
else s=NULL;
rear++;
Q[rear]=s;
if(rear==1){root=s;front=1;}
else if(s&&Q[front]){
if(rear%2==0) Q[front]->lchild=s;
else Q[front]->rchild=s;}
if(rear!=1&&rear%2==1) front++;
}
return root;
}

bitree pre_creat(){ //先根建立 ok
bitree t;
char ch;
cin>>ch;
if(ch=='@') return NULL;
t=new node;
t->data=ch;
t->lchild=pre_creat();
t->rchild=pre_creat();
return t;
}

bitree in_creat(){ //中根建立
bitree t;
char ch;
cin>>ch;
if(ch=='@') return NULL;
t=new node;
t->lchild=pre_creat();
t->data=ch;
t->rchild=pre_creat();
return t;
}

bitree post_creat() { //后根建立
bitree t;
char ch;
cin>>ch;
if(ch=='@') return NULL;
t=new node;
t->lchild=pre_creat();
t->rchild=pre_creat();
t->data=ch;
return t;
}

bitree prein_creat(datatype Pre[],int ps, int pe, datatype In[],int is, int ie){ //先序和中序建立二叉树,ps、pe、is、ie分别为区间的起止节点
bitree t;
int i;
if(ps>pe) return NULL;
t=new node;
t->data=Pre[ps];
i=is;
while(In[i]!=Pre[ps]) i++;
t->lchild=prein_creat(Pre,ps+1,ps+i-is,In,is,i-1);
t->rchild=prein_creat(Pre,ps+i-is+1,pe,In,i+1,ie);
return t;
}

bitree postin_creat(datatype Post[],int ps, int pe, datatype In[],int is, int ie){ //后序和中序建立二叉树,ps、pe、is、ie分别为区间的起止节点
bitree t;
int i;
if(ps>pe) return NULL;
t=new node;
t->data=Post[pe];
i=is;
while(In[i]!=Post[pe]) i++;
t->lchild=postin_creat(Post,ps,ps+i-is-1,In,is,i-1);
t->rchild=postin_creat(Post,ps+i-is,pe-1,In,i+1,ie);
return t;
}

void preorder(bitree t){ //先根遍历
if(t==NULL) return;
cout<<t->data<<endl;
preorder(t->lchild);
preorder(t->rchild);
}

void inorder(bitree t){ //中根遍历
if(t==NULL) return;
inorder(t->lchild);
cout<<t->data<<endl;
inorder(t->rchild);
}

void postorder(bitree t){ //后根遍历
if(t==NULL) return;
postorder(t->lchild);
postorder(t->rchild);
cout<<t->data<<endl;
}

void init_sqqueue(sqqueue &Q){ //循环队列初始化
Q.front=Q.rear=-1;
}

int empty_sqqueue(sqqueue &Q){ //循环队列空判断
if(Q.rear==Q.front) return 1;
else return 0;
}

int en_sqqueue(sqqueue &Q, pointer p){ //入队
if(((Q.rear+1)%maxsize)==Q.front){
cout<<"队满,不能入队!\n"<<endl;
return 0;
}
else{
Q.rear=(Q.rear+1)%maxsize;
Q.data[Q.rear]=p;
return 1;
}

}

int de_sqqueue(sqqueue &Q, pointer &p){ //出队,返回原对头指针
if(Q.rear==Q.front){
cout<<"队空,不能出队\n";
return 0;
}
else{
Q.front=(Q.front+1)%maxsize;
p=Q.data[Q.front];
return 1;
}
}

void levelorder(bitree t){ //层次遍历
pointer p;
sqqueue Q;
if(t==NULL) return;
init_sqqueue(Q);
en_sqqueue(Q,t);
while(!empty_sqqueue(Q)){
de_sqqueue(Q,p);cout<<p->data<<endl;
if(p->rchild!=NULL) en_sqqueue(Q,p->lchild);
if(p->rchild!=NULL) en_sqqueue(Q,p->rchild);

}
/*pointer p;
sqqueue Q;
if(t==NULL) return;
init_sqqueue(&Q);
en_sqqueue(&Q,t);
while(!empty_sqqueue(&Q)){
de_sqqueue(&Q,&p); cout<<p->data<<endl; //出队,访问队头
if(p->lchild!=NULL) en_sqqueue(&Q,p->lchild);
if(p->rchild!=NULL) en_sqqueue(&Q,p->rchild);
}
*/
}

void visit(pointer p){
if(p!=NULL) cout<<p->data<<endl;
else cout<<"error"<<endl;
}

void preorder0(bitree t){ //先根遍历,非递归
pointer p,S[maxsize];
int top;
if(t==NULL) return;
top=-1;
p=t;
while(!(p==NULL&&top==-1)){
while(p!=NULL){
visit(p);
S[++top]=p->rchild;
p=p->lchild;
}
p=S[top--];
}

}

void preorder1(bitree t){ //先根遍历,非递归,根预入栈处理
pointer p,S[maxsize];
int top;
if(t==NULL) return;
top=-1;
S[++top]=t;
while(top>=0) {
p=S[top--];
while(p!=NULL){
visit(p);
S[++top]=p->rchild;
p=p->lchild;
}

}

}

void preorder2(bitree t){ //先根遍历,非递归,预入栈处理
pointer p,S[maxsize];
int top;
if(t==NULL) return;
top=-1;
S[++top]=t;
while(top>=0) {
p=S[top--];
visit(p);
if(p->rchild!=NULL) S[++top]=p->rchild;
if(p->lchild!=NULL) S[++top]=p->lchild;
}
}

void inorder0(bitree t){ //中根遍历,非递归
pointer p,S[maxsize];
int top;
if(t==NULL) return;
top=-1;
p=t;
while(!(p==NULL&&top==-1)){
while(p!=NULL){
S[++top]=p;
p=p->lchild;
}
p=S[top--];
visit(p);
p=p->rchild;
}
}

typedef struct{
pointer p;
int flag;
}stracktype;
void postorder0(bitree t){ //后根遍历、非递归
pointer p;
stracktype S[maxsize];
int top, flag;
if(t==NULL) return;
top=-1;
p=t;
while(!(p==NULL&&top==-1)){
while(p!=NULL){ //进栈
top++;
S[top].p=p;
S[top].flag=1;
p=p->lchild;
}
p=S[top].p; //退栈
flag=S[top].flag;
top--;
if(flag==1){
top++;
S[top].p=p;
S[top].flag=2;
p=p->rchild;
}
else {
visit(p);
p=NULL;
}
}
}

int numleaf=0; //numleaf为叶子数,求二叉树中的叶子节点总数
void leaf(bitree t){

if(t==NULL) return;
if(t->lchild==NULL&&t->rchild==NULL) numleaf++;
leaf(t->lchild);
leaf(t->rchild);

}

int num=0; //num为节点数,求二叉树中的节点总数 ok
void node(bitree t){
if(t==NULL) return;
num++;
node(t->lchild);
node(t->rchild);
}

int degree1=0; //degree1为二叉树中度为1的节点数,求二叉树中度为1的节点总数 ok
void node_degree1(bitree t){
if(t==NULL) return ;
if((t->lchild==NULL&&t->rchild!=NULL)||(t->lchild!=NULL&&t->rchild==NULL)) degree1++;
node_degree1(t->rchild);
node_degree1(t->lchild);

}

int degree2=0; //degree2为二叉树中度为2的节点数,求二叉树中度为2的节点总数 ok
void node_degree2(bitree t){
if(t==NULL) return ;
if(t->lchild!=NULL&&t->rchild!=NULL) degree2++;
node_degree2(t->rchild);
node_degree2(t->lchild);

}

int depth(bitree t){ //求二叉树的高度,depth为树的高度

int l,r,max;
if(t!=NULL)
{
l=depth(t->lchild);
r=depth(t->rchild);
max=l>r?l:r;
return (max+1);
}
else return(0);
}

void del_tree(bitree t){ //二叉树的删除,递归实现 ok
pointer l,r;
if(t==NULL) return; //空树
l=t->lchild; r=t->rchild;
delete t;
del_tree(l);
del_tree(r);

}

void exch_tree(bitree t){ // 交换二叉树的左右子树 ok
pointer p;
if(t==NULL) return; //空树
p=t->lchild;t->lchild=t->rchild;t->rchild=p; //交换
exch_tree (t->rchild);
exch_tree (t->lchild);

}

//层次建立,先根建立,中根建立,后根建立,先序和中序建立,后序和中序建立;先根遍历,中根遍历,后根遍历,层次遍历,非递归的先根遍历,非递归根预入栈处理的先根遍历1,非递归根预入栈处理的先根遍历2,非递归的中根遍历,非递归的后根遍历,求叶子数,求节点数,求二叉树中度为1的节点总数,求二叉树中度为2的节点总数,求二叉树的高度

void main(){
int i,a;
bitree t;
datatype Pre[maxsize],In[maxsize],Post[maxsize];
/* datatype x; */
cout<<"二叉树的操作:0、退出程序,1、层次建立,2、先根建立,3、中根建立,4、后根建立,5、先序和中序建立,6、后序和中序建立;"
<<"7、先根遍历,8、中根遍历,9、后根遍历,10、层次遍历,11、非递归的先根遍历,12、非递归根预入栈处理的先根遍历1,"
<<"13、非递归根预入栈处理的先根遍历2,14、非递归的中根遍历,15、非递归的后根遍历,16、求叶子数,17、求节点数,"
<<"18、求二叉树中度为1的节点总数,19、求二叉树中度为2的节点总数,20、求二叉树的高度,21、二叉树的销毁,22,左右子树的交换"
<<endl;

cout<<"请选择要执行的函数,输入对应的序号"<<endl;
cin>>i;
while(i!=0){
switch(i){
case 1:
t=level_creat();
break;
case 2:
t=pre_creat();
break;
case 3:
t=in_creat();
break;
case 4:
t=post_creat();
break;
case 5:
cout<<"请输入先序序列:"<<endl;
cin>>Pre;
cout<<"请输入中序序列:"<<endl;
cin>>In;
t=prein_creat(Pre,0,strlen(Pre)-1,In,0,strlen(In)-1);
break;
case 6:
cout<<"请输入后序序列:"<<endl;
cin>>Post;
cout<<"请输入中序序列:"<<endl;
cin>>In;
t=postin_creat(Post,0,strlen(Post)-1,In,0,strlen(In)-1);
break;

case 7:
preorder(t);
break;
case 8:
inorder(t);
break;
case 9:
postorder(t);
break;
case 10:
levelorder(t);
break;
case 11:
preorder0(t);
break;
case 12:
preorder1(t);
break;
case 13:
preorder2(t);
break;
case 14:
inorder0(t);
break;
case 15:
postorder0(t);
break;

case 16:
leaf(t);
cout<<"叶子节点数为:"<<numleaf<<endl;
break;
case 17:
node(t);
cout<<"节点数为:"<<num<<endl;
break;
case 18:
node_degree1(t);
cout<<"度为1的节点数为:"<<degree1<<endl;
break;
case 19:
node_degree2(t);
cout<<"度为2的节点数为:"<<degree2<<endl;
break;
case 20:
a=depth(t); cout<<"高度为:"<<a<<endl;
break;
case 21:
del_tree(t);
break;
case 22:
cout<<"交换二叉树的左右子树"<<endl;
exch_tree(t);
cout<<"交换后先跟遍历为:"<<endl;
preorder(t);
break;

}
cout<<"请选择要执行的函数,输入对应的序号"<<endl;
cin>>i;

}

}

这个程序很大的,要把它全给你的话。 你认为你在百度上能看懂么?!~

而且编译完粘过来的没有格式。肯定很乱。

你把邮箱给我,我给你打包过去吧!~

这个作业我们刚做完,呵呵。。

我把包 给你 传过去了 …… 收到后告诉我一声

哦。。这个挺不错哦。。我也下去练习练习

以前写过,晚上回去给你发,我的邮箱xiudewu520@126.com

TSP 遗传算法 C++的程序,急找,高分悬赏~

原来看过个C的遗传算法,不好意思le
#include
#include
#include

/* Change any of these parameters to match your needs */

#define POPSIZE 50 /* population size */
#define MAXGENS 1000 /* max. number of generations */
#define NVARS 3 /* no. of problem variables */
#define PXOVER 0.8 /* probability of crossover */
#define PMUTATION 0.15 /* probability of mutation */
#define TRUE 1
#define FALSE 0

int generation; /* current generation no. */
int cur_best; /* best individual */
FILE *galog; /* an output file */

struct genotype /* genotype (GT), a member of the population */
{
double gene[NVARS]; /* a string of variables */
double fitness; /* GT's fitness */
double upper[NVARS]; /* GT's variables upper bound */
double lower[NVARS]; /* GT's variables lower bound */
double rfitness; /* relative fitness */
double cfitness; /* cumulative fitness */
};

struct genotype population[POPSIZE+1]; /* population */
struct genotype newpopulation[POPSIZE+1]; /* new population; */
/* replaces the */
/* old generation */

/* Declaration of procedures used by this genetic algorithm */

void initialize(void);
double randval(double, double);
void evaluate(void);
void keep_the_best(void);
void elitist(void);
void select(void);
void crossover(void);
void Xover(int,int);
void swap(double *, double *);
void mutate(void);
void report(void);

/***************************************************************/
/* Initialization function: Initializes the values of genes */
/* within the variables bounds. It also initializes (to zero) */
/* all fitness values for each member of the population. It */
/* reads upper and lower bounds of each variable from the */
/* input file `gadata.txt'. It randomly generates values */
/* between these bounds for each gene of each genotype in the */
/* population. The format of the input file `gadata.txt' is */
/* var1_lower_bound var1_upper bound */
/* var2_lower_bound var2_upper bound ... */
/***************************************************************/

void initialize(void)
{
FILE *infile;
int i, j;
double lbound, ubound;

if ((infile = fopen("gadata.txt","r"))==NULL)
{
fprintf(galog,"
Cannot open input file!
");
exit(1);
}

/* initialize variables within the bounds */

for (i = 0; i < NVARS; i++)
{
fscanf(infile, "%lf",&lbound);
fscanf(infile, "%lf",&ubound);

for (j = 0; j < POPSIZE; j++)
{
population[j].fitness = 0;
population[j].rfitness = 0;
population[j].cfitness = 0;
population[j].lower[i] = lbound;
population[j].upper[i]= ubound;
population[j].gene[i] = randval(population[j].lower[i],
population[j].upper[i]);
}
}

fclose(infile);
}

/***********************************************************/
/* Random value generator: Generates a value within bounds */
/***********************************************************/

double randval(double low, double high)
{
double val;
val = ((double)(rand()%1000)/1000.0)*(high - low) + low;
return(val);
}

/*************************************************************/
/* Evaluation function: This takes a user defined function. */
/* Each time this is changed, the code has to be recompiled. */
/* The current function is: x[1]^2-x[1]*x[2]+x[3] */
/*************************************************************/

void evaluate(void)
{
int mem;
int i;
double x[NVARS+1];

for (mem = 0; mem < POPSIZE; mem++)
{
for (i = 0; i < NVARS; i++)
x[i+1] = population[mem].gene[i];

population[mem].fitness = (x[1]*x[1]) - (x[1]*x[2]) + x[3];
}
}

/***************************************************************/
/* Keep_the_best function: This function keeps track of the */
/* best member of the population. Note that the last entry in */
/* the array Population holds a copy of the best individual */
/***************************************************************/

void keep_the_best()
{
int mem;
int i;
cur_best = 0; /* stores the index of the best individual */

for (mem = 0; mem < POPSIZE; mem++)
{
if (population[mem].fitness > population[POPSIZE].fitness)
{
cur_best = mem;
population[POPSIZE].fitness = population[mem].fitness;
}
}
/* once the best member in the population is found, copy the genes */
for (i = 0; i < NVARS; i++)
population[POPSIZE].gene[i] = population[cur_best].gene[i];
}

/****************************************************************/
/* Elitist function: The best member of the previous generation */
/* is stored as the last in the array. If the best member of */
/* the current generation is worse then the best member of the */
/* previous generation, the latter one would replace the worst */
/* member of the current population */
/****************************************************************/

void elitist()
{
int i;
double best, worst; /* best and worst fitness values */
int best_mem, worst_mem; /* indexes of the best and worst member */

best = population[0].fitness;
worst = population[0].fitness;
for (i = 0; i < POPSIZE - 1; ++i)
{
if(population[i].fitness > population[i+1].fitness)
{
if (population[i].fitness >= best)
{
best = population[i].fitness;
best_mem = i;
}
if (population[i+1].fitness <= worst)
{
worst = population[i+1].fitness;
worst_mem = i + 1;
}
}
else
{
if (population[i].fitness <= worst)
{
worst = population[i].fitness;
worst_mem = i;
}
if (population[i+1].fitness >= best)
{
best = population[i+1].fitness;
best_mem = i + 1;
}
}
}
/* if best individual from the new population is better than */
/* the best individual from the previous population, then */
/* copy the best from the new population; else replace the */
/* worst individual from the current population with the */
/* best one from the previous generation */

if (best >= population[POPSIZE].fitness)
{
for (i = 0; i < NVARS; i++)
population[POPSIZE].gene[i] = population[best_mem].gene[i];
population[POPSIZE].fitness = population[best_mem].fitness;
}
else
{
for (i = 0; i < NVARS; i++)
population[worst_mem].gene[i] = population[POPSIZE].gene[i];
population[worst_mem].fitness = population[POPSIZE].fitness;
}
}
/**************************************************************/
/* Selection function: Standard proportional selection for */
/* maximization problems incorporating elitist model - makes */
/* sure that the best member survives */
/**************************************************************/

void select(void)
{
int mem, i, j, k;
double sum = 0;
double p;

/* find total fitness of the population */
for (mem = 0; mem < POPSIZE; mem++)
{
sum += population[mem].fitness;
}

/* calculate relative fitness */
for (mem = 0; mem < POPSIZE; mem++)
{
population[mem].rfitness = population[mem].fitness/sum;
}
population[0].cfitness = population[0].rfitness;

/* calculate cumulative fitness */
for (mem = 1; mem < POPSIZE; mem++)
{
population[mem].cfitness = population[mem-1].cfitness +
population[mem].rfitness;
}

/* finally select survivors using cumulative fitness. */

for (i = 0; i < POPSIZE; i++)
{
p = rand()%1000/1000.0;
if (p < population[0].cfitness)
newpopulation[i] = population[0];
else
{
for (j = 0; j < POPSIZE;j++)
if (p >= population[j].cfitness &&
p<population[j+1].cfitness)
newpopulation[i] = population[j+1];
}
}
/* once a new population is created, copy it back */

for (i = 0; i < POPSIZE; i++)
population[i] = newpopulation[i];
}

/***************************************************************/
/* Crossover selection: selects two parents that take part in */
/* the crossover. Implements a single point crossover */
/***************************************************************/

void crossover(void)
{
int i, mem, one;
int first = 0; /* count of the number of members chosen */
double x;

for (mem = 0; mem < POPSIZE; ++mem)
{
x = rand()%1000/1000.0;
if (x < PXOVER)
{
++first;
if (first % 2 == 0)
Xover(one, mem);
else
one = mem;
}
}
}
/**************************************************************/
/* Crossover: performs crossover of the two selected parents. */
/**************************************************************/

void Xover(int one, int two)
{
int i;
int point; /* crossover point */

/* select crossover point */
if(NVARS > 1)
{
if(NVARS == 2)
point = 1;
else
point = (rand() % (NVARS - 1)) + 1;

for (i = 0; i < point; i++)
swap(&population[one].gene[i], &population[two].gene[i]);

}
}

/*************************************************************/
/* Swap: A swap procedure that helps in swapping 2 variables */
/*************************************************************/

void swap(double *x, double *y)
{
double temp;

temp = *x;
*x = *y;
*y = temp;

}

/**************************************************************/
/* Mutation: Random uniform mutation. A variable selected for */
/* mutation is replaced by a random value between lower and */
/* upper bounds of this variable */
/**************************************************************/

void mutate(void)
{
int i, j;
double lbound, hbound;
double x;

for (i = 0; i < POPSIZE; i++)
for (j = 0; j < NVARS; j++)
{
x = rand()%1000/1000.0;
if (x < PMUTATION)
{
/* find the bounds on the variable to be mutated */
lbound = population[i].lower[j];
hbound = population[i].upper[j];
population[i].gene[j] = randval(lbound, hbound);
}
}
}

/***************************************************************/
/* Report function: Reports progress of the simulation. Data */
/* dumped into the output file are separated by commas */
/***************************************************************/

void report(void)
{
int i;
double best_val; /* best population fitness */
double avg; /* avg population fitness */
double stddev; /* std. deviation of population fitness */
double sum_square; /* sum of square for std. calc */
double square_sum; /* square of sum for std. calc */
double sum; /* total population fitness */

sum = 0.0;
sum_square = 0.0;

for (i = 0; i < POPSIZE; i++)
{
sum += population[i].fitness;
sum_square += population[i].fitness * population[i].fitness;
}

avg = sum/(double)POPSIZE;
square_sum = avg * avg * POPSIZE;
stddev = sqrt((sum_square - square_sum)/(POPSIZE - 1));
best_val = population[POPSIZE].fitness;

fprintf(galog, "
%5d, %6.3f, %6.3f, %6.3f

", generation,
best_val, avg, stddev);
}

/**************************************************************/
/* Main function: Each generation involves selecting the best */
/* members, performing crossover & mutation and then */
/* evaluating the resulting population, until the terminating */
/* condition is satisfied */
/**************************************************************/

void main(void)
{
int i;

if ((galog = fopen("galog.txt","w"))==NULL)
{
exit(1);
}
generation = 0;

fprintf(galog, "
generation best average standard
");
fprintf(galog, " number value fitness deviation
");

initialize();
evaluate();
keep_the_best();
while(generation<MAXGENS)
{
generation++;
select();
crossover();
mutate();
report();
evaluate();
elitist();
}
fprintf(galog,"

Simulation completed
");
fprintf(galog,"
Best member:
");

for (i = 0; i < NVARS; i++)
{
fprintf (galog,"
var(%d) = %3.3f",i,population[POPSIZE].gene[i]);
}
fprintf(galog,"

Best fitness = %3.3f",population[POPSIZE].fitness);
fclose(galog);
printf("Success
");
}
/***************************************************************/
给个旅行商的链接吧~~
http://search.csdn.net/search/tsp/1/lt/?keytype=title

下面是我写的代码,看看符不符合你的要求,有问题就告诉我。
#include
#include
using namespace std;

int main()
{
char filename[150];
char text[4000];
char rate[100];
int i,j;
ifstream infile;
while(1)
{
cout<<"请输入文件名:"<<endl;
cin.getline(filename,150,'
');
infile.open(filename);
if(infile.is_open())
break;
cout<<"打开文件失败,请检查文件名是否正确!"<<endl;
infile.clear();
}
infile.getline(text,4000,'
');
infile.close();
int len=strlen(text);
j=0;
for(i=0;i<len;i+=36)
{
if(text[i]=='4' && text[i+1]=='0')
{
rate[j]=text[i+25];
++j;
}
}
if(i-11>=len)
--j;
cout<<rate[0];
for(i=1;i<j;++i)
cout<<rate[i]<<" ";
cout<<endl;
return 0;
}

相关要点总结:

18371209331:高分悬赏求一C++程序,急急急急急急急急急急急急
柴炒答:int degree1=0; //degree1为二叉树中度为1的节点数,求二叉树中度为1的节点总数 okvoid node_degree1(bitree t){if(t==NULL) return ;if((t->lchild==NULL&&t->rchild!=NULL)||(t->lchild!=NULL&&t->rchild==NULL)) degree1++;node_degree1(t->rchild);node_degree1(t->lchild);}int degre...

18371209331:C语言编写一个程序,急用!!高分悬赏(正确答案追加分数)
柴炒答:include <stdio.h>int main() {int year,id;double a,b,c,d;FILE *infp,*outfp;char infilename[] = "tmp.dat";char outfilename[] = "tmp2.dat";infp = fopen(infilename,"rt");outfp = fopen(outfilename,"wt");if(infp == NULL || outfp == NULL) {printf("无法打开数...

18371209331:急!!![80分]求一C语言程序
柴炒答:int No; //学号 float Chinese; //语文 float math; //数学 float English; //外语 float Sum; //总分 }student[50];//全局变量,记录学生的个数 int n = 0;//根据学号查找是否存在,-1不存在 int isRepeat(int No);/*显示提示信息 6.建立一个菜单,如下图所示 1.依次输入成绩 ...

18371209331:高分悬赏:一个简单C语言程序,相信大神们只需一刻钟就能搞定。需要完整...
柴炒答:include<stdio.h> void average(int *num,int n){ int i;int sum = 0;float aver;for(i=0; i<n; i++){ sum += *(num++);} aver = (float)sum/(float)n;printf("the average of the array is %.2f\n",aver);return ;} void sort(int *num,int *p,int n){ int i,j;...

18371209331:高分悬赏,急寻一个C语言编写的程序。
柴炒答:return 1;} void mainmemu()//主菜单 { int choice;system ("cls");printf ("\n\t\t***学生信息管理系统***");printf ("\n\t\t* *");printf ("\n\t\t* 1.添加学生信息 *");printf ("\n\t\t* *");printf ("\n\t\t* 2.修改学生信息 *");printf ("\n\t\t* *...

18371209331:高分悬赏一道关于个人理财的C语言程序 望高手帮忙!跪求!!
柴炒答:高分悬赏一道关于个人理财的C语言程序 望高手帮忙!跪求!! 给程序的主要功能包括1:理财信息的录入(理财信息包括两部分:收入和支出,每条理财信息包括收支项目序序号收支时间收支项目名称(比如吃饭消费购物消费)收支费用数目.2:理财信息的... 给程序的主要功能包括1:理财信息的录入(理财信息包括两部分:收入和支出,每条...

18371209331:C语言编写一个程序,急用!!高分悬赏(正确答案追加分数)
柴炒答:include void Menu();void Plus();void Minus();void Multiply();void Dir();int main(){ int n, flag = 0;while(1){ Menu();do { flag = 0;scanf("%d", &n);switch(n){ case 1: Plus(); break;case 2: Minus(); break;case 3: Multiply(); break;case 4: Dir(...

18371209331:高分求一道C语言程序 急
柴炒答:printf("1.输入时只输入多项式的系数与指数,以0 0结束.\n");printf("2.例如输入“1 1”然后回车,代表“1*X^1”\n");} void insert(PLOY *head,PLOY *inpt)//查找位置插入新链节程序 {PLOY *pre,*now;int signal=0;pre=head;//pre定义为现在的前一个链节 if(pre->next==NULL) {...

18371209331:求一个C++程序~急!~!!!~要求如下~好的再加分!
柴炒答:问题描述:编制一个统计学生考试分数的管理程序,设学生成绩以一个学生一... 学生成绩管理程序设计目的:实现简单的学生成绩管理系统,在Visual C++ 6.0中进行程序编码、测试、及运行通过。问题描述:编制一个统计学生考试分数的管理程序,设学生成绩以一个学生一个记录的形式存储,每位学生记录包含的信息有:姓名,学号和数学...

18371209331:求编写一下三个简单的C语言程序 ,新手求解
柴炒答:第一个:include <stdio.h>int main(int argc, char *argv[]){ char a; scanf("%c", &a); printf("大写字母为%c\n", a-32); return 0;}第二个:include <stdio.h>int main(int argc, char *argv[]){ char A; scanf("%c", &A); printf("八进制:%o...

(编辑:本站网友)
相关推荐
关于我们 | 客户服务 | 服务条款 | 联系我们 | 免责声明 | 网站地图
@ 百韵网