‘壹’ c语言,如何在按某个键的时候刷新屏幕
#include<stdio.h>
#include<conio.h>
main()
{
chara;
printf("pressaclearscreen");
while(1)
{
a=getch();
if(a=='a')
{
system("cls");
}
}
}
‘贰’ 用c语言编写一个网页刷新器
只要一直发送请求,之后再断开,反复就可以了,间隔时间就是设在循环中,刷新次数用循环控制。
‘叁’ 这个C语言打砖块的代码,砖块如何实现刷新(砖块怎么消失)
c语言游戏中实现动画靠的是1秒钟多于25次的刷新。大一用easyx做过类似的,现在有点忘了,核心思想大概是
while(判断游戏未结束)//时间没停,未触发游戏终止标志
{
for(inti=0;i<objectNum;i++)
{
//根据时间更新每个砖块的状态
//如果某砖块的flag设为被打到,清除该物品,如果是链表删节点
//未被打到,砖块.y更新
}
//画背景图
for(inti=0;i<objectNum;i++)
{
//画每个砖块
}
//获取用户命令
//一旦有命令,DispatchCommand()
//调用那个函数,检测鼠标位置停留的时候是不是按键了,检测有没有操作砖块
//sleep(100ms),延时造成视觉停留
}
‘肆’ C语言中怎样在统计字符时即时刷新
使用getch();函数, 接收字符窜, 不需要按回车键
返回的是输入的字符
头文件为 conio.h
‘伍’ C语言中可不可以对部分数据刷新(清屏),而不是全部清屏
老的16位的PC是可以的,有函数在黑窗第几行第几列定位写输出。
现在的办法是建一个数据表,固定相对位置输出数据,清屏幕一次,全部重写(更新)一次,数值变的重写,数值不变的也重写一遍,就达到“部分数据刷新"
例如下面时间更新程序,变秒。。。,变分。。。
#include<stdio.h>
#include<time.h>
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main ()
{
time_t rt;
struct tm *t;
long int i;
for (i=0;i<3600;i++)
{
time ( &rt );
t = localtime ( &rt );
system("cls");printf("\n\n\n\n\n\n\n\n\t");
printf ( "Year: %d ", t->tm_year+1900 );
printf ( "Month: %d ", t->tm_mon +1 );
printf ( "day: %d ", t->tm_mday);
printf ( "hour: %d ", t->tm_hour);
printf ( "minute: %d ", t->tm_min);
printf ( "second: %d\n", t->tm_sec);
wait (1);
}
return 0;
}
-------
视窗编程,当然可以在任何位置输出和“清屏”,我猜你问的是DOS cmd 窗.
‘陆’ c语言怎么刷新输出时间
由于c语言标准库函数,没有Sleep延时程序,需要自己编写,主要通过循环判断difftime函数返回的时间差来实现延时,具体代码如下,
#include <stdio.h>
#include <time.h>
//延时程序
void sleep(int s)
{
time_t tmp1=time(NULL);
time_t tmp2=tmp1;
while(difftime(tmp2,tmp1)<s)//延时s秒后结束
{
tmp2=time(NULL);
}
}
int main(int argc, char *argv[])
{
int i=1;
while(i)
{
printf ("%d : %s \n",i++,__TIME__);//打印i及程序编译时间
sleep(1);
system("cls"); //清屏
}
return 0;
}
函数double difftime(time_t time2, time_t time1);返回两个time_t型变量之间的时间间隔,即 计算两个时刻之间的时间差。time1计时开始时间,time2计时结束时间,不断更新time2直至(time2-time1)为所需要的延时时间即可。
‘柒’ C语言中写入数据怎样才可以刷新写入谢谢!~
你好!!
不知你向文件输入的是什么数据,输入数据的函数很多,有fputc(s,fp);有fwrite()函数、、、、
下面是想文件输入字符,并把字符串中的小写字符转换成大写字符:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
FILE *fp;
char filename[20];
printf("请输入文件的名称:");
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL)
{
printf("cannot open file !!!\n");
exit(0);
}
printf("请输入字符直至结束(ctrl +z):");
fflush(stdin);
char s;
while(scanf("%c",&s)!=EOF)
{
if(islower(s))
s=toupper(s);//把小写字符转换成大写字符
fputc(s,fp);
}
rewind(fp);//是位置指针重新返回文件的开头,此函数没有返回值
if((fp=fopen(filename,"r"))==NULL)//以读的方式打开文件
{
printf("cannot open file !!!\n");
exit(0);
}
while(!feof(fp))
{
s=getc(fp);
putchar(s);
}
return 0;
}
测试:
请输入文件的名称:hello
请输入字符直至结束(ctrl +z):hello world !
Z
Z
HELLO WORLD !
Press any key to continue
‘捌’ c语言怎么实现一个数,每天刷新一次,我做简单的彩票系统,用了随机数开奖。双色球,怎么让他每天开奖(
如果只是简单的产生随机数很简单,但是如果你要求随机数每天都在刷新的话,那么这个程序需要运行在一个平台上面,并且这个平台可以提供时间,方便的话可以把要求说的再详细一些.
‘玖’ 如何用c语言编写一个程序,功能是循环对一个网页进行刷新,然后对提示的信息选择确定按钮,求代码,谢谢
//CreateList_L.cpp
//To create a LinkList
#include <stdlib.h>
#include <iostream.h>
#include <conio.h>
# define TRUE 1
# define FALSE 0
# define OK 1
# define ERROR 0
# define INFEASIBLE -1
# define OVERFLOW -2
typedef struct DuLNode
{ int data;
struct DuLNode *prior;
struct DuLNode *next;
}DuLNode,*DuLinkList;
// 初始条件:L已存在。操作结果:返回L中数据元素个数
int ListLength(DuLinkList L)
{
int i=0;
DuLinkList p=L->next; // p指向第一个结点
while(p!=L) // p没到表头
{
i++;
p=p->next;
}
return i;
}
// 由双链循环线性表L的头结点出发,正序输出每个数据元素
void ListTraverse(DuLinkList L)
{
DuLinkList p=L->next;
while(p!=L)
{
cout<<p->data<<"\t";
p=p->next;
}
cout<<endl;
}
// 由双链循环线性表L的头结点出发,逆序输出每个数据元素
void ListTraverseBack(DuLinkList L)
{
DuLinkList p=L->prior;
while(p!=L)
{
cout<<p->data<<"\t";
p=p->prior;
}
cout<<endl;
}
//To Creatre a DuLinkList L with HeadNode
void CreateList_DuL(DuLinkList &L)
{
int n;
int i;
DuLNode *p;
L=(DuLinkList)malloc(sizeof(DuLNode));
L->next=L->prior=L;
cout<<"CreateList_L"<<endl<<"================"<<endl;
cout<<"Please input the Init DuLinkNode Number: <eg. 5> ";
cin>>n;
cout<<"Please input the data for DuLinkList Nodes: <eg. 34,67,3,-9,45,...>"<<endl;
for(i=n;i>0;--i)
{
p=(DuLinkList)malloc(sizeof(DuLNode));
cin>>p->data; //Reverse order inputing for Creating a LinkList
p->prior=L;
p->next=L->next;
L->next->prior=p;
L->next=p;
}
if(n)
{
cout<<endl;
cout<<"Success to Create a DuLinkList !"<<endl;
ListTraverse(L);
cout<<endl;
}
else cout<<"A NULL DuLinkList have been created !"<<endl;
}
//ListInsert_Dul()
int ListInsert_DuL(DuLinkList &L)
{
DuLNode *p=L,*s;
int j=0;
int i;
int e;
cout<<"======"<<"before insert:"<<"======"<<endl;
ListTraverse(L);
cout<<"input the location you want to insert:";
cin>>i;
while (i<1||i>ListLength(L)+1)
{
//i值不合法
cout<<"illeagle location,please input the correct location:";
cin>>i;
}
cout<<"input the number you want to insert:";
cin>>e;
while(j<i)
{ p=p->next;
++j;
}
if(!(s=(DuLinkList)malloc(sizeof(DuLNode))))
{
cout<<endl<<"Allocate space failure ! " ;
return (ERROR);
}
s->data=e;
s->prior=p->prior;
s->next=p;
if(i==1)
L->next=s;
p->prior->next=s;
p->prior=s;
cout<<"has insert:"<<e<<endl;
ListTraverse(L);
cout<<"======"<<"after insert:"<<"======"<<endl<<endl;
return (OK);
}
// 删除带头结点的双链循环线性表L的第i个元素,i的合法值为1≤i≤表长
int ListDelete(DuLinkList L)
{
DuLinkList p;
int j=1; // j为计数器
int e;
int i;
cout<<"input the location of the number you want to delete"<<endl;
cin>>i;
while(i<0||i>ListLength(L))
{
//i值不合法
cout<<"illeagle location,please input the correct location:";
cin>>i;
}
p=L->next; // p指向第一个结点
while(p!=L&&j<i) // 顺指针向后查找,直到p指向第i个元素或p指向头结点
{
p=p->next;
j++;
}
if(p==L||j>i) // 第i个元素不存在
{
cout<<"第i个元素不存在"<<endl;
return ERROR;
}
else
{
cout<<"======"<<"before delete:"<<"======"<<endl;
ListTraverse(L);
e=p->data; // 取第i个元素
if(!p) // p=NULL,即第i个元素不存在
return ERROR;
e=p->data;
p->prior->next=p->next;
p->next->prior=p->prior;
free(p);
cout<<"has delete:"<<e<<endl;
ListTraverse(L);
cout<<"======"<<"after delete:"<<"======"<<endl<<endl;
return OK;
}
}
void menu(int c)
{
cout<<"================================================="<<endl;
cout<<"\t\t1----建立"<<endl;
cout<<"\t\t2----插入"<<endl;
cout<<"\t\t3----删除"<<endl;
cout<<"\t\t4----逆置"<<endl;
//cout<<"\t\t5----菜单"<<endl;
cout<<"\t\t0----退出"<<endl;
cout<<"================================================="<<endl;
cout <<endl<<"input you choice number:";
}
void main()
{
DuLinkList L;
int c=1;
while(c!=0)
{
switch(c)
{
case 0:
break;
case 1:
CreateList_DuL(L);
break;
case 2:
ListInsert_DuL(L);
break;
case 3:
ListDelete(L);
break;
case 4:
ListTraverseBack(L);
break;
default:
cout<<"infeasible choice,input again:"<<endl;
menu(c);
cin>>c;
}
if(c!=0)
{
menu(c);
cin>>c;
}
}
}