c语言设计一个网球场使用程序
来源:互联网 发布:opengl游戏编程 编辑:程序博客网 时间:2024/04/28 08:25
#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++;}}}void freeTG(TG* total){char *an = (char*)malloc(sizeof(char)*10);printf("please input agentName you want to free:");scanf("%s", an);int count = 0;while(count < 100){if(strcmp((total+count)->agentName, an) == 0)(total+count)->agentName = " ";count++;}}int main(){int i;int sw;TG *total = (TG*)malloc(sizeof(TG)*100);for(i=0; i<100; i++){(total+i)->num = i; (total+i)->agentName = " ";}while(1){printf("*******Tennis Ground Mallocation******************\n");for(i=0; i<100; i++){printf("%d(%s) ", (total+i)->num, (total+i)->agentName);if(i%5 == 0)printf("\n");}printf("\n");printf("**************************************************\n");printf("Please input your choosen:(1-malloc,2-free):");scanf("%d", &sw);if(sw == 1)mallocTG(total);elsefreeTG(total);}return 0;}
0 0
- c语言设计一个网球场使用程序
- 一个c语言程序
- 使用 C 语言的“准元程序”设计
- 使用c语言完成了一个求素数的程序
- C语言中一个程序多次使用scanf函数
- 使用Dev C++编译运行一个C语言程序
- c语言--菜单设计程序
- 经典C语言程序 设计
- 一个时钟程序(c语言)
- 一个C语言游戏程序
- 一个C语言小程序
- 一个c语言程序而已
- C语言:分步编译一个C程序
- 关于如何找到一个伟大的网球场建设公司
- 使用Python语言设计基于HTML的C语言语法加亮显示程序
- 如何用C语言设计一个程序连接电脑和谷歌眼镜
- C程序使用设计模式
- 什么是c语言程序的模块设计
- Spring3.0官网文档学习笔记(八)--3.4.3~3.4.6
- Java学习总结15——Servlet详解
- 回归(regression)、梯度下降(gradient descent)
- shape文件导入Sql Server 2008R数据库出错
- Windows中Lua环境配置记录
- c语言设计一个网球场使用程序
- 读mybatis源码之十二:结果集处理器
- 数据挖掘笔记-分类-回归算法-最小二乘法
- uboot 源码官方下载地址
- Java实现数据库的连接
- .NET Framework 不同版本之间区别
- Hibernate继承映射之每颗类继承树一张表
- 读mybatis源码之十三:拦截器
- WinDbg+VM9双机调试无法连接解决方案