跪求,C语言程序求助啊。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了跪求,C语言程序求助啊。相关的知识,希望对你有一定的参考价值。
#include<stdio.h>
#include <string.h>
#define SIZE 5
struct car_detail
char registration_num[10];
char model[20];
char colour[10];
double numOfOwners;
;
void addACar(); //加入车
void displayCar(); //显示车
void deleteCar();//删除车
void existSystem();//退出系统
int find_x(char *registrationNum);
struct car_detail showRoom[SIZE]; //Global variables
int index=0;
int main()
char delay;
addACar();
for( ; ; )
printf("\t\t\t\t\t 1.Add a new car into the showroom :\n");
printf("\t\t\t\t\t 2.Delte speicific car in the showroom :\n");
printf("\t\t\t\t\t 3.View all cars in the showroom \n");
printf("\t\t\t\t\t 4.View a speicific car in the show room \n");
printf("\t\t\t\t\t 5.Exit the system");
//end for
delay = getchar();
delay = getchar();
return 0;
//end mqin
void addACar()
if (index < 5)
printf("please enter regsiration number ; \n" );
scanf("%s",showRoom[index].registration_num);
printf("please enter model: \n");
scanf("%s",showRoom[index].model);
printf("please enter color : \n");
scanf("%s",showRoom[index].colour);
index++;
else
printf("The showroom is full");
//end addACar
int find_x(char *registrationNum)
int i;
for (i=0;i < SIZE;i++)
if (strcmp(registrationNum,showRoom[i].registration_num ) == 0)
return i;
//end for
return 0;
void displayCar()
int i;
char registration_num[10];
printf("Please enter car registration number that want to be displayed:");
scanf(" %s",registration_num);
if((i=find_x(registration_num)) == 0)
printf("The registration number is not exist :");
return ;
printf("Registration number:%s\n",showRoom[i].registration_num);
printf(" car mode :%s\n",showRoom[i].model);
printf("colour : %s\n",showRoom[i].colour);
printf(" number of previous owner:%lf\n",showRoom[i].numOfOwners);
return ;
//end displayCar
void deleteCar()
int i
registrationNum[10];
printf("Please enter car registrtaion number:");
scanf(" %s",registrationNum);
if((i=find_x(registration_num))==0)
1.请帮我把deleteCar()写完,要求是:
找到registration_nuim然后,要求是再删除车的时候,将所有的元素搬到右边去,一个位置到左边。 例如如果共有五辆车,希望删除第三辆车,第四辆车必须移动第三辆的位置,第五辆车覆盖第四两个车的位置。如果没有找到registration_num,错误的信息提示。
2.最后请把我把exitSystem()写下。
3.顺便能帮我改下Menu的内容谢谢。
4.写一个函数,显示所有车的信息在showRoom里面
printf("1.Add a new car into the showroom :\n"); //按1就会addCar()
printf(" 2.Delte speicific car in the showroom :\n");//按2就会deleteCar()
printf(" 3.View all cars in the showroom \n"); //按3就会displayCar()
printf(" 4.View a speicific car in the show room \n");
printf(" 5.Exit the system");//退出系统
如果太长了,请发到我百度消息
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 5
#define ADD 1
#define DEL 2
#define SHOWALL 3
#define SHOWONE 4
#define EXIT 5
struct car_detail
char registration_num[10];
char model[20];
char colour[10];
double numOfOwners;
;
void addACar(); //加入车
void displayCar(); //显示车
void deleteCar();//删除车
void existSystem();//退出系统
int find_x(char *registrationNum);
struct car_detail showRoom[SIZE]; //Global variables
int index=0;
bool run = true;
void addACar()
if(index < 5)
printf("please enter regsiration number:" );
scanf("%s",showRoom[index].registration_num);
printf("please enter model:");
scanf("%s",showRoom[index].model);
printf("please enter color:");
scanf("%s",showRoom[index].colour);
index++;
else
printf("The showroom is full");
//end addACar
int find_x(char *registrationNum)
int i;
for (i=0; i < SIZE; i++)
if (strcmp(showRoom[i].registration_num, registrationNum) == 0)
return i;
//end for
printf("---Can not find the car---\n");
return 0;
void displayAllCar()
int i;
if(index == 0)
printf("No car exist!\n");
for(i = 0; i < index; i++)
printf("Registration number:%s\n",showRoom[i].registration_num);
printf("car mode:%s\n",showRoom[i].model);
printf("colour:%s\n",showRoom[i].colour);
printf("number of previous owner:%lf\n",showRoom[i].numOfOwners);
void displayOneCar()
int i;
char registration_num[10];
printf("Please enter car registration number that want to be displayed:");
scanf("%s",registration_num);
if((i=find_x(registration_num)) == 0)
printf("The registration number is not exist :");
return ;
printf("Registration number:%s\n",showRoom[i].registration_num);
printf("car mode:%s\n",showRoom[i].model);
printf("colour:%s\n",showRoom[i].colour);
printf("number of previous owner:%lf\n",showRoom[i].numOfOwners);
return ;
//end displayCar
void deleteCar()
int i;
char registrationNum[10];
printf("Please enter car registrtaion number:");
scanf("%s",registrationNum);
if((i=find_x(registrationNum)) !=0)
for(; i < SIZE-1; i++)
strncpy(showRoom[i].registration_num, showRoom[i+1].registration_num, 10);
strncpy(showRoom[i].model, showRoom[i+1].model, 20);
strncpy(showRoom[i].colour, showRoom[i+1].colour, 10);
showRoom[i].numOfOwners = showRoom[i+1].numOfOwners;
index--;
else
printf("car num error\n");
void showmenu()
printf(" 1.Add a new car into the showroom :\n"); //按1就会addCar()
printf(" 2.Delte speicific car in the showroom :\n");//按2就会deleteCar()
printf(" 3.View all cars in the showroom \n"); //按3就会displayCar()
printf(" 4.View a speicific car in the show room \n");
printf(" 5.Exit the system\n");//退出系统
printf("Enter your choise:");
void existSystem()
printf("system exit...\n");
run = false;
int main( void )
int cmd;
while(run)
showmenu();
scanf("%d", &cmd);
switch(cmd)
case ADD:
addACar();
break;
case DEL:
deleteCar();
break;
case SHOWALL:
displayAllCar();
break;
case SHOWONE:
displayOneCar();
break;
case EXIT:
existSystem();
break;
default:
printf("Unknown cmd!\n");
break;
return 0;
参考技术A #include<stdio.h>
#include <string.h>
#define SIZE 5
struct car_detail
char registration_num[10];
char model[20];
char colour[10];
double numOfOwners;
你会97年的第三题骑士游历问题,跪求啊,救命用啊谢谢啊,回头给积分,要多少给多少,谢谢
骑士游历(1997年全国青少年信息学(计算机)奥林匹克分区联赛高中组复赛试题第三题)
设有一个n×m的棋盘(2<=n<=50,2<=m<=50),如图1,在棋盘上任一点有一个中国象棋马,
以上是关于跪求,C语言程序求助啊。的主要内容,如果未能解决你的问题,请参考以下文章
c语言中 如何单独运行一个子函数啊?或者说怎样验证一个子函数的正确性、以及其功能啊?求助···
跪求大神指导。我用C#做了一个小程序,可以将一个txt文档中的参数读出,用dictionary列列