华为笔试题01

华为笔试题目

华为笔试题(一)

2006年华为研发类笔试编程题

题目:网球中心共有100个网球场,每个单位可以来申请1到100的场地,申请的场地编号必须是连续的,如果场地已经被其他单位占用,就不能再次使用,而且单位在使用完场地后必须归还。请设计一个完整的系统(c语言)。(限时5分钟)

Tennis.h

struct TennisGround

{

int num;

char *agentName;

};

typedef struct TennisGround TG;

void mallocTG(TG *total);

void freeTG(TG *total);

Tennis.c

#include <stdio.h>

#include <stdlib.h>

#include <malloc.h>

#include <string.h>

#include "Tennis.h"

void mallocTG(TG *total)

{

int size, start,count = 0;

char *agentName = (char*)malloc(sizeof(char)*10);

printf("Please input your agentName:");

scanf("%s", agentName);

printf("Please input the size of the TennisGround:");

scanf("%d", &size);

printf("Please input the TennisGround number you want to start:");

scanf("%d", &start);

if((total+start)->agentName != " ")

{

printf("malloc failed!\n");

exit(-1);

}

else

{

while(count < size)

{

(total+start+count)->agentName = agentName;

count++;

}

你可能喜欢

  • 温度传感器的应用
  • 优化策略
  • 提高课堂教学质量
  • 投资书籍
  • 幼儿园评估
  • 数据库优化
  • 加强人才队伍建设
  • 风险承受能力

华为笔试题01相关文档

最新文档

返回顶部