当前位置: 代码迷 >> C语言 >> 哪个高手帮我改一下main函数啊
  详细解决方案

哪个高手帮我改一下main函数啊

热度:168   发布时间:2005-11-28 17:55:00.0
哪个高手帮我改一下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  

----------------解决方案--------------------------------------------------------
http://bbs.bc-cn.net/bbs/dispbbs.asp?boardID=5&ID=35373&page=1

4,7楼
----------------解决方案--------------------------------------------------------
int a=1,while(a==1)不是构成死循环了吗
----------------解决方案--------------------------------------------------------
太长了 眼花

----------------解决方案--------------------------------------------------------
  相关解决方案