面向对象程序设计C++经典例题3Word文件下载.docx
- 文档编号:15380072
- 上传时间:2022-10-29
- 格式:DOCX
- 页数:31
- 大小:21.59KB
面向对象程序设计C++经典例题3Word文件下载.docx
《面向对象程序设计C++经典例题3Word文件下载.docx》由会员分享,可在线阅读,更多相关《面向对象程序设计C++经典例题3Word文件下载.docx(31页珍藏版)》请在冰豆网上搜索。
printf("
\1:
Thedifferentis%6.3f\n"
difftime(end,start));
时间函数举例3
{clock_tstart,end;
doublevar;
start=clock();
10000;
end=clock();
(double)(end-start));
时间函数举例4,一个猜数游戏,判断一个人反应快慢。
(版主初学时编的)
stdlib.h"
{charc;
clock_tstart,end;
time_ta,b;
inti,guess;
srand(time(NULL));
doyouwanttoplayit.('
y'
or'
n'
)\n"
loop:
while((c=getchar())=='
)
{
i=rand()%100;
\npleaseinputnumberyouguess:
\n"
a=time(NULL);
scanf("
%d"
&
guess);
while(guess!
=i)
{if(guess>
i)
{printf("
pleaseinputalittlesmaller.\n"
else
pleaseinputalittlebigger.\n"
b=time(NULL);
Ittookyou%6.3fseconds\n"
var=(double)(end-start)/18.2);
ittookyou%6.3fseconds\n\n"
difftime(b,a));
if(var<
15)
\1\1Youareveryclever!
\1\1\n\n"
elseif(var<
25)
\1\1youarenormal!
\1\1youarestupid!
\1\1Congradulations\1\1\n\n"
Thenumberyouguessis%d"
i);
\ndoyouwanttotryitagain?
(\"
yy\"
.or.\"
n\"
)\n"
if((c=getch())=='
gotoloop;
家庭财务管理小程序
/*moneymanagementsystem*/
dos.h"
FILE*fp;
structdated;
floatsum,chm=0.0;
intlen,i,j=0;
intc;
charch[4]="
"
ch1[16]="
chtime[12]="
chshop[16],chmoney[8];
pp:
clrscr();
sum=0.0;
gotoxy(1,1);
|---------------------------------------------------------------------------|"
gotoxy(1,2);
|moneymanagementsystem(C1.0)2000.03|"
gotoxy(1,3);
gotoxy(1,4);
|--moneyrecords--|--todaycostlist--|"
gotoxy(1,5);
|------------------------|-------------------------------------|"
gotoxy(1,6);
|date:
--------------||"
gotoxy(1,7);
|||||"
gotoxy(1,8);
|--------------||"
gotoxy(1,9);
|thgs:
------------------||"
gotoxy(1,10);
gotoxy(1,11);
|------------------||"
gotoxy(1,12);
|cost:
----------||"
gotoxy(1,13);
gotoxy(1,14);
|----------||"
gotoxy(1,15);
|||"
gotoxy(1,16);
gotoxy(1,17);
gotoxy(1,18);
gotoxy(1,19);
gotoxy(1,20);
gotoxy(1,21);
gotoxy(1,22);
gotoxy(1,23);
i=0;
getdate(&
d);
sprintf(chtime,"
%4d.%02d.%02d"
d.da_year,d.da_mon,d.da_day);
for(;
;
gotoxy(
103f
3,24);
Tab__browsecostlistEsc__quit"
gotoxy(13,10);
"
gotoxy(13,13);
gotoxy(13,7);
%s"
chtime);
j=18;
ch[0]=getch();
if(ch[0]==27)
break;
strcpy(chshop,"
strcpy(chmoney,"
if(ch[0]==9)
mm:
fp=fopen("
home.dat"
"
r+"
gotoxy(3,24);
gotoxy(6,4);
listrecords"
|-------------------------------------|"
gotoxy(41,4);
gotoxy(41,5);
|"
while(fscanf(fp,"
%10s%14s%f\n"
chtime,chshop,&
chm)!
=EOF)
{if(i==36)
{getch();
if((i%36)<
17)
{gotoxy(4,6+i);
gotoxy(4,6+i);
if((i%36)>
16)
{gotoxy(41,4+i-17);
gotoxy(42,4+i-17);
i++;
sum=sum+chm;
%10s%-14s%6.1f\n"
chtime,chshop,chm);
gotoxy(1,24);
||"
gotoxy(1,25);
gotoxy(10,24);
totalis%8.1f$"
sum);
fclose(fp);
gotoxy(49,24);
pressanykeyto....."
getch();
gotopp;
while(ch[0]!
='
\r'
{if(j<
10)
{strncat(chtime,ch,1);
j++;
if(ch[0]==8)
len=strlen(chtime)-1;
if(j>
{len=len+1;
j=11;
strcpy(ch1,"
j=j-2;
strncat(ch1,chtime,len);
strcpy(chtime,"
strncat(chtime,ch1,len-1);
gotomm;
exit
(1);
j=0;
{if(j<
14)
{strncat(chshop,ch,1);
{len=strlen(chshop)-1;
strncat(ch1,chshop,len);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 面向 对象 程序设计 C+ 经典 例题