当前位置:首页 » 编程语言 » 百行C语言

百行C语言

发布时间: 2022-04-23 14:58:24

❶ 如何用c语言做游戏开发

你错了~ 理论上说,其他语言做到的c语言一定能够做到~而且效率高得多,只不过其他语言一句话就能做到的,C语言可能要上百行代码~ c语言时代,一个大软件 动辄几十万行,几百万行代码,其中出一个错误,是绝对令人抓狂的,所以有c++,java,。net 等应运而生~ linux 系统是纯c语言写的哦~ 也能有vista 那样美的图形用户界面~ 发明c语言的人真的很了不起~ 从汇编的角度看C语言是垃圾,从C语言的角度看其他语言,同样是垃圾~
其中也包括了怀旧的 MAX 3 界面(3DSMaxR3.cui)。当然如果你有足够的时间和耐心,也可以自己设计...

❷ 求一个c语言编程题 超过三百行

23根火柴游戏
完整注释版本

#include<iostream>
#include<string>
#include<ctime>
#define NUM 20
using namespace std;

void main()
{
//规则的输出
cout<<endl;
cout<<"***************************************************"<<endl;
cout<<"游戏规则:共有23根火柴,2个人依次拿取,每个人每次只"<<endl;
cout<<"能拿1跟或者2跟或者3跟火柴。拿到最后一跟火柴的人算输"<<endl;
cout<<"****************************************************"<<endl;
cout<<endl;
//变量的定义
int match_num=23; //火柴数目
int *p_match_num; //指向火柴数目的指针
int player = 0; //玩家变量,偶数代表玩家,奇数代表电脑
char player_name[NUM]; //玩家的名字
char player_computer[NUM]="computer";
char judge; //判断变量,值为'y'时,表示玩家先开局
int put_num=0; //拿走火柴的数目
char *p_player_now;
int *p_put_num; //指向拿走火柴数目的指针
int *p_player;
//指针赋值
p_match_num=&match_num;
p_put_num=&put_num;
p_player=&player;
p_player_now=player_name;
//函数的定义
void match(int* p_match_num,int* p_put_num,int* p_player); //拿走火柴数目
//游戏开始
cout<<"请输入玩家的名字:";
gets(player_name);
//玩家开局顺序的选择
cout<<"玩家“"<<player_name<<"”选择拿火柴顺序(“F(First)/S(Second)”)";
cin>>judge;
if(judge=='s')
{
p_player_now=player_computer;
player++;
}
cout<<"从“"<<p_player_now<<"”开始游戏。"<<player;
cout<<endl;
//火柴的拿取
while(1)
{
match(p_match_num,p_put_num,p_player);
if(match_num==0)
{
if(player%2==0)
p_player_now=player_name;
else
p_player_now=player_computer;
cout<<"玩家“"<<p_player_now<<"”您输了!"<<endl;
cout<<player<<endl;
break;
}
}
}

void match(int* p_match_num,int* p_put_num,int* p_player)
{
if((*p_player)%2==0)
{
cout<<"请输入准备拿走火柴的数目:";
cin>>*p_put_num;
while(*p_put_num!=1 && *p_put_num!=2 && *p_put_num!=3 || *p_match_num-*p_put_num<0)
{
if(*p_put_num!=1 && *p_put_num!=2 && *p_put_num!=3)
{
cout<<"您输入的数值不合法,拿走的火柴数目只能是 1 或 2 或 3,请重新输入:";
cin>>*p_put_num;
}
if(*p_match_num-*p_put_num<0)
{
cout<<"您输入的数值大于剩余火柴数目,请重新输入:";
cin>>*p_put_num;
}
}
cout<<"您拿走的火柴数目是: "<<*p_put_num<<endl;
cout<<"剩余火柴数目是: "<<*p_match_num-*p_put_num<<endl;
}
else
{
srand((int)time(0));
*p_put_num=rand()%3;
while(*p_put_num!=1 && *p_put_num!=2 && *p_put_num!=3 || *p_match_num-*p_put_num<0)
{
*p_put_num=rand()%3;
}
cout<<"computer拿走的火柴数目是:"<<*p_put_num<<endl;
cout<<"剩余火柴数目是: "<<*p_match_num-*p_put_num<<endl;
}
*p_match_num=*p_match_num-*p_put_num;
cout<<endl;
if(*p_match_num!=0)
(*p_player)++;
}

❸ c语言大作业 最少100行 写什么啊

这是以前我自己写的一个加密解密的程序,一共有175行,不过因为其中写了两种加密方法和两种对应的解密方法,而且用函数将他们区分开来,还用菜单做了选项,所以你只要直接删除其中一种方法的加解密函数就可以了,这个字符串加解密是对字符串比较全的操作,对你学习c会有帮助,而且也不难看懂,你可以看下,不懂可以通过网络hi问我(encrypt函数是加密函数decrypt是解密函数,数字1和2表示第一种加密方式,第二种加密方式)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
FILE *file=NULL;
void main()
{
void set(char*,int*,int*);
void encrypt1(char*,const int*);
void decrypt1(char*,const int*);
void encrypt2(char*,const int*);
void decrypt2(char*,const int*);
char content[100000]="";
int key1[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
int key2[2]={0};
char press='\0';
do
{
printf("*********************************\n");
printf("1.设置加密方法\n");
printf("2.加密方法1\n");
printf("3.加密方法2\n");
printf("4.解密方法1\n");
printf("5.解密方法2\n");
printf("6.退出\n");
printf("*********************************\n");
printf("选择操作步骤(1-6):\n");
switch(press=getch())
{
case '1':set(content,key1,key2);break;
case '2':encrypt1(content,key1);break;
case '3':encrypt2(content,key2);break;
case '4':decrypt1(content,key1);break;
case '5':decrypt2(content,key2);break;
default:break;
}
}while(press!='6');
if(file!=NULL)
{
rewind(file);
fputs(content,file);
printf("文件或字符串的内容为:\n");
puts(content);
fclose(file);
}
}
void set(char content[100000],int key1[10],int key2[2])
{
long int key;
char ch;
int i;
char str[100]="";
if(file!=NULL)
{
fclose(file);
file=NULL;
}
printf("输入字符串或者文件完整路径:");
gets(str);
if(file=fopen(str,"r+"))
{
printf("输入的是文件完整路径,内容为:\n");
while(fgetc(file)!=EOF)
{
fseek(file,-1,1);
fgets(content,100000,file);
printf("%s",content);
}
}
else
{
file=fopen("content.txt","w+");
strcpy(content,str);
printf("输入的是字符串,内容为:\n");
puts(content);
}
printf("\n设置密码:");
gets(str);
for(i=0;(i<strlen(str))&&(i<10);i++)
*(key1+i)=*(str+i)-'0';
key=atoi(str);
key2[0]=(key%11>=3)?(key%11):3;
for(key2[1]=1,i=0;i<10;i++)
if((*(key1+i)>key2[1])&&(*(key1+i)<key2[0]))
key2[1]=*(key1+i);
}
void encrypt1(char content[100000],const int key1[10])
{
int j,k;
for(j=0,k=0;j<strlen(content);j++)
{
*(content+j)+=*(key1+k);
k++;
if(k==9||*(key1+k)==-1)
k=0;
if(*(content+j)>=122)
*(content+j)%=122;
}
}
void decrypt1(char content[100000],const int key1[10])
{
int j,k;
for(j=0,k=0;j<strlen(content);j++)
{
*(content+j)-=*(key1+k);
k++;
if(k==9||*(key1+k)==-1)
k=0;
if(*(content+j)>=122)
*(content+j)%=122;
}
}
void encrypt2(char content[100000],const int key2[2])
{
char precontent[100000],str[11]="",ch;
int i,j,p;
p=key2[0];
strcpy(precontent,content);
strcpy(content,"");
for(i=0;i<strlen(precontent);)
{
if(strlen(precontent)-i<key2[0])
p=strlen(precontent)-i;
for(j=p-1;j>=0;j--)
*(str+j)=*(precontent+i++);
if(p==key2[0])
{
ch=*(str);
*(str)=*(str+key2[1]);
*(str+key2[1])=ch;
}
else
{
ch=*(str);
*(str)=*(str+p-1);
*(str+p-1)=ch;
}
strcat(content,str);
for(j=0;j<p;j++)
*(str+j)='\0';
if(p!=key2[0])
break;
}
}
void decrypt2(char content[100000],const int key2[2])
{
char precontent[100000],str[11]="",ch;
int i,j,p;
p=key2[0];
strcpy(precontent,content);
strcpy(content,"");
for(i=0;i<strlen(precontent);)
{
if(strlen(precontent)-i<key2[0])
p=strlen(precontent)-i;
for(j=p-1;j>=0;j--)
*(str+j)=*(precontent+i++);
if(p==key2[0])
{
ch=*(str+p-1);
*(str+p-1)=*(str+p-1-key2[1]);
*(str+p-1-key2[1])=ch;
}
else
{
ch=*(str);
*(str)=*(str+p-1);
*(str+p-1)=ch;
}
strcat(content,str);
for(j=0;j<11;j++)
*(str+j)='\0';
if(p!=key2[0])
break;
}
}

❹ C语言老师布置作业让编写几百行的程序,请教各位编写个什么好呢

链表的插入删除合并拆分排序够了

❺ 谁能给我一个C语言四五百行的程序代码,结业设计用

//学生信息管理系统
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct student
{
char num[20];
char name[20];
int score1;
int score2;
int score3;
}stu[100]={"01","zhangmingming",67,78,82,"02","lichengyou",78,91,88,"03","zhanghuican",68,82,56,"04","wanglu",56,45,77,"05","chendongming",67,38,47};
int main()
{
int i;
int s=5;
void cjtj();
void xxwh();
void xxcx();
void cjpx();
FILE *fp1;
if((fp1=fopen("stu_list","w"))==NULL) /*以只写的方式打开一个文件stu_list*/
{
printf("Can not open file!\n");
exit(1);
}
fwrite(&stu,sizeof(struct student),5,fp1); /*将stu中的数据写到文件中*/
fclose(fp1);
do
{
printf("\n");
printf("\n");
printf(" +--------------------+\n");
printf(" |欢迎使用学生管理系统|\n");
printf(" | |\n");
printf(" | 请按照步骤操作 |\n");
printf(" | 1.信息维护 |\n");
printf(" | 2.信息查询 |\n");
printf(" | 3.成绩统计 |\n");
printf(" | 4.成绩排序 |\n");
printf(" | 0.退出程序 |\n");
printf(" +--------------------+\n");
printf(" 请选择您要进行的操作:");
scanf("%d",&i);
if(i==1)
{
xxwh();
}
else if(i==2)
{
xxcx();
}
else if(i==3)
{
cjtj();
}
else if(i==4)
{
cjpx();
}
else
break;
}while(i!=0);
printf("谢谢使用!\n");
return 0;
}
void cjtj() /*成绩统计子函数*/
{
char name[20];
system("cls");
printf("请输入您想统计的课程名称:\n");
scanf("%s",name);
int q,w,u,s,g,p,k,l,m;
if(strcmp(name,"yuwen")==0)
{
printf("请输入您想统计的分数段(例60,70):\n");
scanf("%d,%d",&q,&w);

for(u=0;u<5;u++)
{
if((stu[u].score1>=q)&&(stu[u].score1<=w))
printf("%s %s %d %d %d\n",stu[u].num,stu[u].name,stu[u].score1,stu[u].score2,stu[u].score3);
}
}
if(strcmp(name,"shuxue")==0)
{
printf("请输入您想统计的分数段(例60,70):\n");
scanf("%d,%d",&s,&g);
for(p=0;p<5;p++)
{
if(stu[p].score2>=s&&g>=stu[p].score2)
printf("%s %s %d %d %d\n",stu[p].num,stu[p].name,stu[p].score1,stu[p].score2,stu[p].score3);
}
}
if(strcmp(name,"yingyu")==0)
{
printf("请输入您想统计的分数段(例60,70):\n");
scanf("%d,%d",&k,&l);
for(m=0;m<5;m++)
{
if(stu[m].score3>=k&&stu[m].score3<=l)
printf("%s %s %d %d %d\n",stu[m].num,stu[m].name,stu[m].score1,stu[m].score2,stu[m].score3);
}
}

return;
}
void xxwh() /* 信息维护子函数*/
{
int y;
int s=5;
void zengjia();
void shanjian();
void xiugai();
do
{
printf(" --------------------\n");
printf(" 欢迎进入信息维护模块\n");
printf(" 1.增加学生信息 \n");
printf(" 2.删减学生信息 \n");
printf(" 3.修改学生信息 \n");
printf(" 4.退出本模块 \n");
printf(" --------------------\n");
printf(" 请输入您要进行的操作(1-4):");
scanf("%d",&y);
if(y==1)
{
zengjia();
s=s+1;
}
else if(y==2)
{
shanjian();
s=s-1;
}
else if(y==3)
{
xiugai();
}
else
break;
}while(y!=4);
printf("谢谢使用!\n");
return;
}
void zengjia() /*增加学生信息*/
{
struct student student1;
FILE *fp1;
int n=5;
printf("输入您想添加的学生信息:\n");
scanf("%s %s%d%d%d",student1.num,student1.name,&student1.score1,&student1.score2,&student1.score3);
strcpy(stu[n+1].num,student1.num);
strcpy(stu[n+1].name,student1.name);
stu[n+1].score1=student1.score1;
stu[n+1].score2=student1.score2;
stu[n+1].score3=student1.score3;
if((fp1=fopen("stu_list","r+"))==NULL) /*以读写的方式打开一个文件stu_list*/
{
printf("Can not open file!\n");
exit(1);
}
fwrite(&stu,sizeof(struct student),6,fp1); /*将stu中的数据写到文件中*/
fclose(fp1);
printf("\n");
printf("添加成功!\n");
printf("\n");
printf("\n");
return;
}
void shanjian() /*删除学生信息*/
{
char a[20];
int h,j,e;
FILE *fp1;
printf("请输入您想删除的学生学号:\n");
scanf("%s",a);
for(h=0;h<5;h++)
{
if(strcmp(a,stu[h].num)==0)
j=h;
}
if(j!=4)
{
for(e=h-1;e<5;e++,j++)
{
strcpy(stu[j].num,stu[j+1].num);
strcpy(stu[j].name,stu[j+1].name);
stu[j].score1=stu[j+1].score1;
stu[j].score2=stu[j+1].score2;
stu[j].score3=stu[j+1].score3;
}
}
if((fp1=fopen("stu_list","r+"))==NULL) /*以读写的方式打开一个文件stu_list*/
{
printf("Can not open file!\n");
exit(1);
}
fwrite(&stu,sizeof(struct student),6,fp1); /*将stu中的数据写到文件中*/
fclose(fp1);
printf("\n");
printf("删除成功!\n");
printf("\n");
printf("\n");
return;
}
void xiugai() /*修改学生信息*/
{
char b[20];
int c,n=5;
FILE *fp1;
struct student student2;
printf("请输入您想修改的学生学号:\n");
scanf("%s",b);
for(c=0;c<n;c++)
{
if(strcmp(b,stu[c].num)==0)
{
printf("请输入修改后的学生信息:\n");
scanf("%s %s%d%d%d",student2.num,student2.name,&student2.score1,&student2.score2,&student2.score3);
strcpy(stu[c].num,student2.num);
strcpy(stu[c].name,student2.name);
stu[c].score1=student2.score1;
stu[c].score2=student2.score2;
stu[c].score3=student2.score3;
}
} if((fp1=fopen("stu_list","r+"))==NULL) /*以读写的方式打开一个文件stu_list*/
{
printf("Can not open file!\n");
exit(1);
}
fwrite(&stu,sizeof(struct student),6,fp1); /*将stu中的数据写到文件中*/
fclose(fp1);
fclose(fp1);
printf("\n");
printf("修改成功!\n");
printf("\n");
printf("\n");
return;
}
void cjpx() /*排序函数*/
{
int z,x,c,v,o;
struct student t;
do
{
printf("\n");
printf("\n");
printf("[1]按升序排序:\n");
printf("[2]按降序排序:\n");
printf("[3]返回\n");
printf("请选择:");
scanf("%d",&z);
if(z==1)
{
printf("选择的科目:");
printf("[1]语文:[2]数学:[3]英语:");
scanf("%d",&x);
if(x==1)
{
for(c=1;c<5;c++)
for(v=0;v<5-c;v++)

if(stu[v].score1>stu[v+1].score1)
{
t=stu[v];
stu[v]=stu[v+1];
stu[v+1]=t;
}
for(o=0;o<5;o++)
printf("%s %s %d %d %d\n",stu[o].num,stu[o].name,stu[o].score1,stu[o].score2,stu[o].score3);
}
else if(x==2)
{
for(c=1;c<5;c++)
for(v=0;v<5-c;v++)
if(stu[v].score2>stu[v+1].score2)
{
t=stu[v];
stu[v]=stu[v+1];
stu[v+1]=t;
}
for(o=0;o<5;o++)
printf("%s %s %d %d %d\n",stu[o].num,stu[o].name,stu[o].score1,stu[o].score2,stu[o].score3);
}
else if(x==3)
{
for(c=1;c<5;c++)
for(v=0;v<5-c;v++)
if(stu[v].score3>stu[v+1].score3)
{
t=stu[v];
stu[v]=stu[v+1];
stu[v+1]=t;
}
for(o=0;o<5;o++)
printf("%s %s %d %d %d\n",stu[o].num,stu[o].name,stu[o].score1,stu[o].score2,stu[o].score3);
}
}
else
if(z==2)
{
printf("选择的科目:");
printf("[1]语文:[2]数学:[3]英语:");
scanf("%d",&x);
if(x==1)
{
for(c=1;c<5;c++)
for(v=0;v<5-c;v++)
if(stu[v].score1<stu[v+1].score1)
{
t=stu[v+1];
stu[v+1]=stu[v];
stu[v]=t;
}
for(o=0;o<5;o++)
printf("%s %s %d %d %d\n",stu[o].num,stu[o].name,stu[o].score1,stu[o].score2,stu[o].score3);
}
else
if(x==2)
{
for(c=1;c<5;c++)
for(v=0;v<5-c;v++)

if(stu[v].score2<stu[v+1].score2)
{
t=stu[v+1];
stu[v+1]=stu[v];
stu[v]=t;
}
for(o=0;o<5;o++)
printf("%s %s %d %d %d\n",stu[o].num,stu[o].name,stu[o].score1,stu[o].score2,stu[o].score3);
}
else
if(x==3)
{
for(c=1;c<5;c++)
for(v=0;v<5-c;c++)

if(stu[v].score3<stu[v+1].score3)
{
t=stu[v+1];
stu[v+1]=stu[v];
stu[v]=t;
}
for(o=0;o<5;o++)
printf("%s %s %d %d %d\n",stu[o].num,stu[o].name,stu[o].score1,stu[o].score2,stu[o].score3);
}
}
else
break;
}while(z!=3);
printf("\n");
printf("\n");
return;
}
void xxcx() /*信息查询子函数*/
{
int g,i;
char m[20];
system("cls");
do
{
printf("[1]查询学生信息:\n");
printf("[2]退出查询:\n");
printf("请选择:");
scanf("%d",&g);
if(g==1)
{
printf("请输入学号:");
scanf("%s",m);
for(i=0;i<5;i++)
{
if(strcmp(m,stu[i].num)==0)
{
printf("*********\n");
printf("学号:%s\n",stu[i].num);
printf("姓名:%s\n",stu[i].name);
printf("语文:%d\n",stu[i].score1);
printf("数学:%d\n",stu[i].score2);
printf("英语:%d\n",stu[i].score3);
printf("\n");
printf("\n");
}
}
}
else
break;
}while(g!=2);
printf("查找完毕!\n");
system("pause");
return;
}

❻ c语言游戏编程

你错了~
理论上说,其他语言做到的c语言一定能够做到~而且效率高得多,只不过其他语言一句话就能做到的,C语言可能要上百行代码~
c语言时代,一个大软件
动辄几十万行,几百万行代码,其中出一个错误,是绝对令人抓狂的,所以有c++,java,。net
等应运而生~
linux
系统是纯c语言写的哦~
也能有vista
那样美的图形用户界面~
发明c语言的人真的很了不起~
从汇编的角度看C语言是垃圾,从C语言的角度看其他语言,同样是垃圾~
其中也包括了怀旧的
MAX
3
界面(3DSMaxR3.cui)。当然如果你有足够的时间和耐心,也可以自己设计...

❼ 求3百行左右可在VC运行的C语言程序的编码,希望是原创的

无任何要求的很简单的

你自己把一段小说弄下来
定义个几个字符串
然后打印出来即可~
凑个300行随便咯

你不说要求,谁知道怎么做。

❽ 给我一个C语言程序要求百行以上,谢谢

红黑树的一个演示程序,不一定完全正确
大概300+吧

// Copyright 1988-2006 By Zor X. Liu

#include <stdio.h>
#include <conio.h>

enum Color { red,black };

struct RBTNode
{
int dat;
Color c;
RBTNode *p,*l,*r;
};

RBTNode *root,*nil;

RBTNode* Insert(int);
void Delete(RBTNode*);
RBTNode* Successor(RBTNode*);
RBTNode* Minium(RBTNode*);
RBTNode* Search(int);
void LeftRotate(RBTNode*);
void RightRotate(RBTNode*);
void InorderWalk(RBTNode*);
void PreorderWalk(RBTNode*);
void Free(RBTNode*);

int main()
{
nil=new RBTNode;
nil->c=black,nil->dat=0;
nil->p=nil->r=nil->l=NULL;

RBTNode *tmp;
int choice,dat;
while(true)
{
clrscr();
printf("------------------------------\n");
printf("Current:");InorderWalk(root);printf("\n");
printf("------------------------------\n");
printf(" 1.Insert\n");
printf(" 2.Delete\n");
printf(" 3.Preorder Walk\n");
printf(" q.Quit\n");
printf("------------------------------\n");
do {
choice=getch();
} while(choice!='q'&&(choice>'3'||choice<'1'));
if(choice=='q')
break;
if(choice=='1'||choice=='2')
{
printf("Data:");
scanf("%d",&dat);
}
switch(choice)
{
case '1':
Insert(dat);
printf("Inserted.\n");
break;
case '2':
tmp=Search(dat);
if(!tmp)
{
printf("Cannot find it.\n");
break;
}
Delete(tmp);
printf("Deleted.\n");
break;
case '3':
PreorderWalk(root);
break;
}
getch();
}
return 0;
}

void InorderWalk(RBTNode* x)
{
if(x!=nil&&x)
{
InorderWalk(x->l);
printf("%d",x->dat);
if(x->c==red)
printf("r ");
else
printf("b ");
InorderWalk(x->r);
}
}

void PreorderWalk(RBTNode* x)
{
if(x!=nil&&x)
{
printf("%d",x->dat);
if(x->c==red)
printf("r ");
else
printf("b ");
PreorderWalk(x->l);
PreorderWalk(x->r);
}
}

void Free(RBTNode* x)
{
if(x!=nil&&x)
{
Free(x->l);
Free(x->r);
delete x;
}
}

RBTNode* Search(int dat)
{
RBTNode *x=root;
if(root)
{
while(x!=nil)
{
if(dat==x->dat)
return x;
else
if(dat>x->dat)
x=x->r;
else
x=x->l;
}
}
return NULL;
}

RBTNode* Minium(RBTNode* x)
{
while(x->l!=nil)
x=x->l;
return x;
}

RBTNode* Successor(RBTNode* x)
{
if(x->r)
return Minium(x->r);

RBTNode *y=x->p;
while(y&&x==y->r)
{
x=y;
y=y->p;
}
return y;
}

void LeftRotate(RBTNode* x)
{
RBTNode *y=x->r,*z=x->p;
if(y!=nil)
{
x->p=y;
x->r=y->l;y->l->p=x;
y->p=z;
y->l=x;
if(y->p)
if(x==y->p->l)
y->p->l=y;
else
y->p->r=y;
else
root=y;
}
}

void RightRotate(RBTNode* x)
{
RBTNode *y=x->l,*z=x->p;
if(y!=nil)
{
x->p=y;
x->l=y->r;y->r->p=x;
y->p=z;
y->r=x;
if(y->p)
if(y->p->l==x)
y->p->l=y;
else
y->p->r=y;
else
root=y;
}
}

RBTNode* Insert(int dat)
{
RBTNode *n;
n=new RBTNode;
n->dat=dat,n->c=red;
n->p=NULL,n->l=n->r=nil;

if(!root)
{
root=n;
n->c=black;
return n;
}

RBTNode *x=root,*y=NULL;
while(x!=nil)
{
y=x;
if(dat>x->dat)
x=x->r;
else
x=x->l;
}
n->p=y;
if(dat>y->dat)
y->r=n;
else
y->l=n;

if(y->c==red)
{
x=n;
while(x->p->p&&x->c==red&&x->p->c==red)
{
if(x->p->p->l==x->p)
{
y=x->p->p->r;
if(y->c==red)
{
x->p->p->c=red;
x->p->c=y->c=black;
x=x->p->p;
}
else
{
if(x==x->p->r)
{
LeftRotate(x->p);
x=x->l;
}
x->p->c=black;
x->p->p->c=red;
RightRotate(x->p->p);
}
}
else
{
y=x->p->p->l;
if(y->c==red)
{
x->p->p->c=red;
x->p->c=y->c=black;
x=x->p->p;
}
else
{
if(x==x->p->l)
{
RightRotate(x->p);
x=x->r;
}
x->p->c=black;
x->p->p->c=red;
LeftRotate(x->p->p);
}
}
}
}
root->c=black;
}

void Delete(RBTNode* x)
{
RBTNode *y,*z;
if(x->l==nil||x->r==nil)
y=x;
else
y=Successor(x);

if(y->l!=nil)
z=y->l;
else
z=y->r;

z->p=y->p;
if(y->p)
if(y==y->p->r)
y->p->r=z;
else
y->p->l=z;
else
root=z,z->p=NULL;

if(y!=x)
x->dat=y->dat;
if(y->c==black)
{
x=z;
while(x!=root&&x->c==black)
{
if(x==x->p->l)
{
z=x->p->r;
if(z->c==red)
{
x->p->c=red;
z->c=black;
LeftRotate(x->p);
}
if(z->c==black)
{
if(z->l->c==z->r->c==black)
{
z->c=red;
x=x->p;
}
else if(z->l->c==red&&z->r->c==black)
{
RightRotate(z);
z=z->p;
}
if(z->r->c==red)
{
z->r->c=black;
z->c=z->p->c;
z->p->c=black;
LeftRotate(z->p);
x=root;
}
}
}
else
{
z=x->p->l;
if(z->c==red)
{
x->p->c=red;
z->c=black;
RightRotate(x->p);
}
if(z->c==black)
{
if(z->r->c==z->l->c==black)
{
z->c=red;
x=x->p;
}
else if(z->r->c==red&&z->l->c==black)
{
LeftRotate(z);
z=z->p;
}
if(z->l->c==red)
{
z->l->c=black;
z->c=z->p->c;
z->p->c=black;
RightRotate(z->p);
x=root;
}
}
}
}
}
delete y;
}

❾ 编写一个几百行代码的C语言程序 存储数据用结构体还是链表好

要看你是怎样应用了。你要动态分配,那肯定是链表了。如果你要便于直接访问,那就结构体数组。

❿ C 几百行代码python却几行c 值得吗

  1. 不要去比较这些,没有任何意义。存在即合理,C语言有C语言擅长的,Python有Python擅长的领域。

  2. 对于程序员来说,语言不是障碍,更重要的是逻辑思维、算法、排错能力和大局观。

最后,别再纠结这类问题了。

热点内容
古玩源码 发布:2025-07-17 18:22:49 浏览:87
ie浏览历史文件夹 发布:2025-07-17 18:07:05 浏览:261
php还是c 发布:2025-07-17 18:02:57 浏览:456
androidasp 发布:2025-07-17 17:57:34 浏览:475
采访直播脚本 发布:2025-07-17 17:53:46 浏览:881
怎样启用远程访问 发布:2025-07-17 17:52:19 浏览:559
c删除文件夹中的文件 发布:2025-07-17 17:52:17 浏览:487
我的世界梦服务器地址 发布:2025-07-17 17:30:30 浏览:323
c语言函数传递参数 发布:2025-07-17 17:24:50 浏览:923
ftp自动备份怎么用 发布:2025-07-17 17:19:41 浏览:887