陌上_桑 2013-08-19 03:48 采纳率: 0%
浏览 3201

C语言数字动态显示问题

#include
#include
#include
#include
#include
#include
struct SevenD_point
{
int X,Y,Z_C,Z_N,Z_P,U_P,U_M;
};
int check(char *input,char *container)
{
int i,j;
for(i=0,j=0;i {
if(strcmp(input,container+40*i)==0)
{
if(j!=6)
{
printf("System check that you wanna %s.\n",container+40*i);
break;
}
else
{
printf("Program Terminated!");
break;
}
}
else j++;
}
if(j==7)
printf("System cannot check what you wanna do,please check input.\n");
return j;
}
void Initialize()
{
long Max(struct SevenD_point *p);
void disp(struct SevenD_point *p);
struct SevenD_point Present={rand(),rand(),rand(),rand(),rand(),rand(),rand()},*p;
int i;
long max;
p=&Present;
printf("Present position:(%d,%d,%d,%d,%d,%d,%d).\n",\
Present.X,Present.Y,Present.Z_C,Present.Z_N,Present.Z_P,Present.U_P,Present.U_M);
max=Max(p);
printf("Now start to decrease %ld times:\n",max+1);
for(;max>0;max--)
{
disp(p);
}
printf("\nInitialize position accomplished!\nAnd now position is(%d,%d,%d,%d,%d,%d,%d).\n",\
Present.X,Present.Y,Present.Z_C,Present.Z_N,Present.Z_P,Present.U_P,Present.U_M);
delay(500);
}
void Change()
{
}
void Add()
{
}
void Oscillate()
{
}
void Small()
{
}
void Big()
{
}
long Max(struct SevenD_point *p)
{
long z_max,u_max,zu_max,xy_max,max;
z_max=((p->Z_C)>(p->Z_N))?(p->Z_C):(p->Z_N);
z_max=(z_max>(p->Z_P))?z_max:(p->Z_P);
u_max=((p->U_P)>(p->U_M))?(p->U_P):(p->U_M);
zu_max=(z_max>u_max)?z_max:u_max;
xy_max=((p->X)>(p->Y))?(p->X):(p->Y);
max=zu_max+xy_max;
return max;
}
void disp(struct SevenD_point *p)
{
int i;
long z,u,x,y;
z=(p->Z_C)+(p->Z_N)+(p->Z_P);
u=(p->U_P)+(p->U_M);
x=(p->X),y=(p->Y);
if(z>0)
{
if((p->Z_C)>0)
(p->Z_C)--;
if((p->Z_N)>0)
(p->Z_N)--;
if((p->Z_P)>0)
(p->Z_P)--;
}
if(u>0)
{
if((p->U_P)>0)
(p->U_P)--;
if((p->U_M)>0)
(p->U_M)--;
}
if((z==0)&&(u==0))
{
if(x>0)
(p->X)--;
if(y>0)
(p->Y)--;
}
printf("Present Point (7-Dimension):(%5d,%5d,%5d,%5d,%5d,%5d,%5d)",\
p->X,p->Y,p->Z_C,p->Z_N,p->Z_P,p->U_P,p->U_M);
for(i=0;i<71;i++)
printf("\b");
}

void main()
{
char func[7][40]={"Initialize position","Change medicine",\
"Add medicine","Oscillate sample",\
"Fetch and Spit sample","All over in",\
"Abort"},excute[40];
int choose=7;
srand((unsigned)time(NULL));
while(choose==7)
{
printf("Please tell what you wanna do:");
gets(excute);
choose=check(excute,func[0]);
}
if(choose==0)
Initialize();
}
这是源程序,不完整,但是可以运行

奇怪的是每次运行提示输入后,输入Initialize position,执行的结果都不一样。按照我的想法是每次闪烁到最后都应该是0才对。请高手看看,能不能指导指导什么地方的问题,小弟不胜感激。
我的操作系统是Win7 32位旗舰版,所用的编译器是Turbo C 3.0.

还有就是C的转义字符里面有没有哪个是直接回到上一行的?就是说光标本来在第六行,有什么转义字符能让他回到第五行?

  • 写回答

1条回答 默认 最新

  • Aiome 2015-07-24 14:37
    关注

    哥们、问问题也是一门学问

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作