| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 622 人关注过本帖
标题:哪个高手帮我改一下main函数啊
只看楼主 加入收藏
bennyhe
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2005-11-28
收藏
 问题点数:0 回复次数:3 
哪个高手帮我改一下main函数啊

#include <stdlib.h>
int map[32][32];
create()
{
int i,j;
for(i=0;i<32;i++)
{
for(j=0;j<32;j++)
if(map[i][j]==1)
continue;
else
{map[i][j]=1;break;}

break;
}
printf("the new map is :\n");
for(i=0;i<32;i++)
{ printf("\n");
for(j=0;j<32;j++)
printf("%2d",map[i][j]);
}
printf("\n");
}
int open(int a)
{
int line,row;
line=a/32;
row=a%32;
if(map[line][row]==1)
{
printf("open file successfull!!\n");
return 1;
}
else
{
printf("the file is not exist ,open error!!\n ");
return 0;
}
}
read(int a)
{
int i;
if(open(a))
{
printf("read...\n");
for(i=0;i<1000;i++)
;
printf("read file successfull!!\n");
}
else
printf("the file is not exist!!\n");
printf("read file error!!\n");
}
/*write(int a)
{
int i,j;
if(open(a))
{
for(i=0;i<32;i++)
{
for(j=0;j<32;j++)
{
if(map[i][j]==0)
{
printf("you can write the file now!\n");
map[i][j]=1;
}
else
printf("there is no space to write now!!\n");
break;
}
break;
}
}
else
printf("the file is not exist !write error!\n");
for(i=0;i<32;i++)
{
printf("\n");
for(j=0;j<32;j++)
printf("%2d",map[i][j]);
}
}*/
close(int a)
{
int line,row;
line=a/32;
row=a%32;
if((line<32)&&(row<32)&&(map[line][row]))
printf("close the file successful!!\n");
else
printf("the file is not exist ,close file error!!\n");
}
delete(int a)
{
int i,j;
int line,row;
line=a/32;
row=a%32;
if(map[line][row]==1)
{
map[line][row]=0;
printf("delete the file succussefull!!\n");
}
else
printf("the file is not exist,delete error!!");
for(i=0;i<32;i++)
{
printf("\n");
for(j=0;j<32;j++)
printf("%2d",map[i][j]);
}
printf("\n");
}
main()
{
int a=1;
int choice,address;
do
{
printf("input 1 to create the file\n");
printf("input 2 to open the file\n");
printf("input 3 to read the file\n");
/*printf("input 4 to write the file\n");*/
printf("input 5 to close the file\n");
printf("input 6 to delete the file\n");
printf("input 7 to exit this programe\n");
printf("please input your choice:\n");
scanf("%d",&choice);
switch(choice)
{
case 1 : {create();break;}
case 2 : {printf("input the file address:");scanf("%d",&address);open(address);break;}
case 3 : {printf("input the file address:");scanf("%d",&address);read(address);break;}
/*case 4 : {printf("input the file address:");scanf("%d",&address);write(address);break;}*/
case 5 : {printf("input the file address:");scanf("%d",&address);close(address);break;}
case 6 : {printf("input the file address:");scanf("%d",&address);delete(address);break;}
case 7 : {a=0;break;}
default : printf("input error!!try again\n");
}
}while(a==1);
}
为什么在scanf函数是没停下来啊?
不胜感激!!

搜索更多相关主题的帖子: main 函数 printf map 
2005-11-28 17:55
Knocker
Rank: 8Rank: 8
等 级:贵宾
威 望:47
帖 子:10454
专家分:603
注 册:2004-6-1
收藏
得分:0 

九洲方除百尺冰,映秀又遭蛮牛耕。汽笛嘶鸣国旗半,哀伤尽处是重生。     -老K
治国就是治吏。礼义廉耻,国之四维。四维不张,国之不国。   -毛泽东
2005-11-28 21:02
dingrf
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-12-4
收藏
得分:0 
int a=1,while(a==1)不是构成死循环了吗
2005-12-04 19:48
追风牛
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2005-12-4
收藏
得分:0 
太长了 眼花

你可以嘲笑我 但那不会太久!
2005-12-04 23:22
快速回复:哪个高手帮我改一下main函数啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026343 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved