【程序91】
题目:时间函数举例1
1.程序分析:
2.程序源代码:
#include
"stdio.h"
#include "time.h"
void main()
{ time_t lt; /*define a
longint time varible*/
lt=time(NULL);/*system time and
date*/
printf(ctime(<)); /*english format
output*/
printf(asctime(localtime(<)));/*tranfer to
tm*/
printf(asctime(gmtime(<))); /*tranfer to Greenwich
time*/
}
==============================================================
【程序92】
题目:时间函数举例2
1.程序分析:
2.程序源代码:
/*calculate
time*/
#include "time.h"
#include "stdio.h"
main()
{ time_t
start,end;
int i;
start=time(NULL);
for(i=0;i<3000;i++)
{
printf("\1\1\1\1\1\1\1\1\1\1\n");}
end=time(NULL);
printf("\1: The
different is
%6.3f\n",difftime(end,start));
}
==============================================================
【程序93】
题目:时间函数举例3
1.程序分析:
2.程序源代码:
/*calculate
time*/
#include "time.h"
#include "stdio.h"
main()
{ clock_t
start,end;
int i;
double
var;
start=clock();
for(i=0;i<10000;i++)
{
printf("\1\1\1\1\1\1\1\1\1\1\n");}
end=clock();
printf("\1: The
different is
%6.3f\n",(double)(end-start));
}
==============================================================
【程序94】
题目:时间函数举例4,一个猜数游戏,判断一个人反应快慢。(版主初学时编的)
1.程序分析:
2.程序源代码:
#include
"time.h"
#include "stdlib.h"
#include "stdio.h"
main()
{char
c;
clock_t start,end;
time_t a,b;
double var;
int
i,guess;
srand(time(NULL));
printf("do you want to play it.('y' or
'n')
\n");
loop:
while((c=getchar())=='y')
{
i=rand()%100;
printf("\nplease
input number you
guess:\n");
start=clock();
a=time(NULL);
scanf("%d",&guess);
while(guess!=i)
{if(guess>i)
{printf("please
input a little
smaller.\n");
scanf("%d",&guess);}
else
{printf("please input
a little
bigger.\n");
scanf("%d",&guess);}
}
end=clock();
b=time(NULL);
printf("\1:
It took you %6.3f seconds\n",var=(double)(end-start)/18.2);
printf("\1:
it took you %6.3f
seconds\n\n",difftime(b,a));
if(var<15)
printf("\1\1 You are very
clever! \1\1\n\n");
else if(var<25)
printf("\1\1 you are normal!
\1\1\n\n");
else
printf("\1\1 you are stupid!
\1\1\n\n");
printf("\1\1 Congradulations \1\1\n\n");
printf("The
number you guess is %d",i);
}
printf("\ndo you want to try it
again?(\"yy\".or.\"n\")\n");
if((c=getch())=='y')
goto
loop;
}
==============================================================
【程序95】
题目:家庭财务管理小程序
1.程序分析:
2.程序源代码:
/*money
management system*/
#include "stdio.h"
#include
"dos.h"
main()
{
FILE *fp;
struct date d;
float
sum,chm=0.0;
int len,i,j=0;
int c;
char
ch[4]="",ch1[16]="",chtime[12]="",chshop[16],chmoney[8];
pp:
clrscr();
sum=0.0;
gotoxy(1,1);printf("|---------------------------------------------------------------------------|");
gotoxy(1,2);printf("|
money management system(C1.0) 2000.03
|");
gotoxy(1,3);printf("|---------------------------------------------------------------------------|");
gotoxy(1,4);printf("|
-- money records -- | -- today cost list -- |");
gotoxy(1,5);printf("|
------------------------
|-------------------------------------|");
gotoxy(1,6);printf("| date:
-------------- | |");
gotoxy(1,7);printf("| | | |
|");
gotoxy(1,8);printf("| -------------- |
|");
gotoxy(1,9);printf("| thgs: ------------------ |
|");
gotoxy(1,10);printf("| | | | |");
gotoxy(1,11);printf("|
------------------ | |");
gotoxy(1,12);printf("| cost: ---------- |
|");
gotoxy(1,13);printf("| | | | |");
gotoxy(1,14);printf("|
---------- | |");
gotoxy(1,15);printf("| |
|");
gotoxy(1,16);printf("| | |");
gotoxy(1,17);printf("| |
|");
gotoxy(1,18);printf("| | |");
gotoxy(1,19);printf("| |
|");
gotoxy(1,20);printf("| | |");
gotoxy(1,21);printf("| |
|");
gotoxy(1,22);printf("| |
|");
gotoxy(1,23);printf("|---------------------------------------------------------------------------|");
i=0;
getdate(&d);
sprintf(chtime,"%4d.%02d.%02d",d.da_year,d.da_mon,d.da_day);
for(;;)
{
gotoxy(3,24);printf("
Tab __browse cost list Esc __quit");
gotoxy(13,10);printf("
");
gotoxy(13,13);printf("
");
gotoxy(13,7);printf("%s",chtime);
j=18;
ch[0]=getch();
if(ch[0]==27)
break;
strcpy(chshop,"");
strcpy(chmoney,"");
if(ch[0]==9)
{
mm:i=0;
fp=fopen("home.dat","r+");
gotoxy(3,24);printf("
");
gotoxy(6,4);printf(" list records
");
gotoxy(1,5);printf("|-------------------------------------|");
gotoxy(41,4);printf("
");
gotoxy(41,5);printf("
|");
while(fscanf(fp,"%10s%14s%f\n",chtime,chshop,&chm)!=EOF)
{
if(i==36)
{ getch();
i=0;}
if ((i%36)<17)
{
gotoxy(4,6+i);
printf("
");
gotoxy(4,6+i);}
else
if((i%36)>16)
{
gotoxy(41,4+i-17);
printf("
");
gotoxy(42,4+i-17);}
i++;
sum=sum+chm;
printf("%10s %-14s
%6.1f\n",chtime,chshop,chm);}
gotoxy(1,23);printf("|---------------------------------------------------------------------------|");
gotoxy(1,24);printf("|
|");
gotoxy(1,25);printf("|---------------------------------------------------------------------------|");
gotoxy(10,24);printf("total
is %8.1f$",sum);
fclose(fp);
gotoxy(49,24);printf("press any key
to.....");getch();goto pp;
}
else
{
while(ch[0]!='\r')
{
if(j<10)
{
strncat(chtime,ch,1);
j++;}
if(ch[0]==8)
{
len=strlen(chtime)-1;
if(j>15)
{
len=len+1;
j=11;}
strcpy(ch1,"");
j=j-2;
strncat(ch1,chtime,len);
strcpy(chtime,"");
strncat(chtime,ch1,len-1);
gotoxy(13,7);printf("
");}
gotoxy(13,7);printf("%s",chtime);ch[0]=getch();
if(ch[0]==9)
goto
mm;
if(ch[0]==27)
exit(1);
}
gotoxy(3,24);printf("
");
gotoxy(13,10);
j=0;
ch[0]=getch();
while(ch[0]!='\r')
{
if (j<14)
{ strncat(chshop,ch,1);
j++;}
if(ch[0]==8)
{
len=strlen(chshop)-1;
strcpy(ch1,"");
j=j-2;
strncat(ch1,chshop,len);
strcpy(chshop,"");
strncat(chshop,ch1,len-1);
gotoxy(13,10);printf("
");}
gotoxy(13,10);printf("%s",chshop);ch[0]=getch();}
gotoxy(13,13);
j=0;
ch[0]=getch();
while(ch[0]!='\r')
{
if (j<6)
{ strncat(chmoney,ch,1);
j++;}
if(ch[0]==8)
{
len=strlen(chmoney)-1;
strcpy(ch1,"");
j=j-2;
strncat(ch1,chmoney,len);
strcpy(chmoney,"");
strncat(chmoney,ch1,len-1);
gotoxy(13,13);printf("
");}
gotoxy(13,13);printf("%s",chmoney);ch[0]=getch();}
if((strlen(chshop)==0)||(strlen(chmoney)==0))
continue;
if((fp=fopen("home.dat","a+"))!=NULL);
fprintf(fp,"%10s%14s%6s",chtime,chshop,chmoney);
fputc('\n',fp);
fclose(fp);
i++;
gotoxy(41,5+i);
printf("%10s
%-14s %-6s",chtime,chshop,chmoney);
}}}
==============================================================
【程序96】
题目:计算字符串中子串出现的次数
1.程序分析:
2.程序源代码:
#include
"string.h"
#include "stdio.h"
main()
{ char
str1[20],str2[20],*p1,*p2;
int sum=0;
printf("please input two
strings\n");
scanf("%s%s",str1,str2);
p1=str1;p2=str2;
while(*p1!='\0')
{
if(*p1==*p2)
{while(*p1==*p2&&*p2!='\0')
{p1++;
p2++;}
}
else
p1++;
if(*p2=='\0')
sum++;
p2=str2;
}
printf("%d",sum);
getch();}
==============================================================
【程序97】
题目:从键盘输入一些字符,逐个把它们送到磁盘上去,直到输入一个#为止。
1.程序分析:
2.程序源代码:
#include
"stdio.h"
main()
{ FILE *fp;
char
ch,filename[10];
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL)
{printf("cannot
open
file\n");
exit(0);}
ch=getchar();
ch=getchar();
while(ch!='#')
{fputc(ch,fp);putchar(ch);
ch=getchar();
}
fclose(fp);
}
==============================================================
【程序98】
题目:从键盘输入一个字符串,将小写字母全部转换成大写字母,然后输出到一个磁盘文件“test”中保存。
输入的字符串以!结束。
1.程序分析:
2.程序源代码:
#include "stdio.h"
main()
{FILE
*fp;
char str[100],filename[10];
int
i=0;
if((fp=fopen("test","w"))==NULL)
{ printf("cannot open the
file\n");
exit(0);}
printf("please input a
string:\n");
gets(str);
while(str[i]!='!')
{
if(str[i]>='a'&&str[i]<='z')
str[i]=str[i]-32;
fputc(str[i],fp);
i++;}
fclose(fp);
fp=fopen("test","r");
fgets(str,strlen(str)+1,fp);
printf("%s\n",str);
fclose(fp);
}
==============================================================
【程序99】
题目:有两个磁盘文件A和B,各存放一行字母,要求把这两个文件中的信息合并(按字母顺序排列),
输出到一个新文件C中。
1.程序分析:
2.程序源代码:
#include
"stdio.h"
main()
{ FILE *fp;
int i,j,n,ni;
char
c[160],t,ch;
if((fp=fopen("A","r"))==NULL)
{printf("file A cannot be
opened\n");
exit(0);}
printf("\n A contents are
:\n");
for(i=0;(ch=fgetc(fp))!=EOF;i++)
{c[i]=ch;
putchar(c[i]);
}
fclose(fp);
ni=i;
if((fp=fopen("B","r"))==NULL)
{printf("file
B cannot be opened\n");
exit(0);}
printf("\n B contents are
:\n");
for(i=0;(ch=fgetc(fp))!=EOF;i++)
{c[i]=ch;
putchar(c[i]);
}
fclose(fp);
n=i;
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
if(c[i]>c[j])
{t=c[i];c[i]=c[j];c[j]=t;}
printf("\n
C file is:\n");
fp=fopen("C","w");
for(i=0;i<n;i++)
{
putc(c[i],fp);
putchar(c[i]);
}
fclose(fp);
}
==============================================================
【程序100】
题目:有五个学生,每个学生有3门课的成绩,从键盘输入以上数据(包括学生号,姓名,三门课成绩),计算出
平均成绩,况原有的数据和计算出的平均分数存放在磁盘文件"stud"中。
1.程序分析:
2.程序源代码:
#include
"stdio.h"
struct student
{ char num[6];
char name[8];
int
score[3];
float avr;
} stu[5];
main()
{int i,j,sum;
FILE
*fp;
/*input*/
for(i=0;i<5;i++)
{ printf("\n please input No.
%d
score:\n",i);
printf("stuNo:");
scanf("%s",stu[i].num);
printf("name:");
scanf("%s",stu[i].name);
sum=0;
for(j=0;j<3;j++)
{
printf("score
%d.",j+1);
scanf("%d",&stu[i].score[j]);
sum+=stu[i].score[j];
}
stu[i].avr=sum/3.0;
}
fp=fopen("stud","w");
for(i=0;i<5;i++)
if(fwrite(&stu[i],sizeof(struct
student),1,fp)!=1)
printf("file write
error\n");
fclose(fp);
}
相关推荐
Python经典编程习题100例,供初学者学习
题目及题解持续更新中 – – – – – – – – – – 1 11 21 31 41 51 61 71 81 91 2 12 22 32 42 52 62 72 82 92 3 13 23 33 43 53 63 73 83 93 4 14 24 34 44 54 64 74 84 94 5 15 25 35 45 55 65 75 85 95 6 16 26 36 46 56 66 76 86 96 7 17 27 37 47 57 67 77 87 97
经典C语言程序100例(91-100)------------转自C语言经典论坛
【程序91】题目:时间函数举例11.程序分析:2.程序源代码:#include "stdio.h"#include "time.h"void main(){ time_t lt; /*define a longint time varible*/lt=time(NULL);/*system time and date*/printf(ctime(printf(asctime(localtime(p
【win11】主板更新之后pin不可用,恢复方法
台式机的主板更新了BIOS,再开机竟然登录不进去系统了。 登录界面上显示:【由于此设备上的安全设置已更改,你的pin码不再可用。单击以重新设置pin】 点击【单击以重新设置pin】没有任何反应。 也没有密码登录选项。 在网上找到解决方法,不用PE,只需要按步骤操作即可。通过实际验证可行,现记录如下。
C语言经典100例程序教程
C语言 经典100题 C语言入门
python机器人编程——用pytorch实现六轴机械臂的正向和逆向数值解算,及python算法解析
前面对六轴(或多轴)机械臂进行了一些研究,特别是利用几何进行简化,实现逆解,来完成比较简单的搬用任务。然而,如果需要比较精确的操作任务,可能需要更加复杂的机械臂解算。其中比较复杂的是数值解算,这种解算往往涉及到比较复杂的机器人运动等原理知识,比较难以上手。但是,python的生态挺全面,已经有很多牛人实现了数值解法,但是去看他们的代码,还是觉得费劲。此外,随着深度神经网络的兴起,很多是用建立深度学习神经网络,去利用机械臂输入输出的大数据,训练机械臂的控制模型,这个上手也比较慢。
物联网技术-第2章-物联网技术架构
• 物联网具有很强的异构性• 为实现异构设备之间的互联、互通与互操作,物联网需要以一个开放的分层的可扩展的为框架。
经典c语言程序100例(91-100)
题目:从键盘输入一个字符串,将小写字母全部转换成大写字母,然后输出到一个磁盘文件“test”中保存。题目:有五个学生,每个学生有3门课的成绩,从键盘输入以上数据(包括学生号,姓名,三门课成绩),计算出。题目:有两个磁盘文件A和B,各存放一行字母,要求把这两个文件中的信息合并(按字母顺序排列),平均成绩,况原有的数据和计算出的平均分数存放在磁盘文件"stud"中。题目:时间函数举例4,一个猜数游戏,判断一个人反应快慢。题目:从键盘输入一些字符,逐个把它们送到磁盘上去,直到输入一个#为止。
CUBEMX ADC 单/多通道+DMA
本文使用的是STM3F103C8T6 Cubemx进行单/多通道DMA配置。
C++ 经典 100 例程序教程
C++ 100例经典习题
core_analyzer分析c++程序内存占用
环境:centos; 进程:单进程多线程c++程序; 问题:1. 分析系统内存占用; 2. 分析ptmalloc内存空洞(bins上的空闲chunk的大小); 包括:1. 占用了很大内存的c++进程; 2. gcore(在进程不core dump的情况下生成core文件); 3. core_analyzer(分析gcor...
apollo自动驾驶进阶学习之:如何实现施工路段限速绕行及其参数调试
首先需要理解Planning模块是基于Scenario、Stage、Task这样的层次来进行的,即场景->步骤->具体的决策方法。Apollo可以应对自动驾驶所面临的不同道路场景,都是通过Scenario统一注册与管理。Scenario通过一个有限状态机来判断选择当前行车场景,每个Scenario下又有多个Stage,指当前场景下需要执行的粗略步骤。.........
【C语言基础案例目录】经典C语言程序设计100例目录(附100例题目)
《C语言基础案例目录》精选100个经典程序设计案例,分为10个部分(每部分10例),涵盖数字组合、奖金计算、完全平方数等基础算法。案例由浅入深,包含素数判断、水仙花数、斐波那契数列等数学问题,以及递归、绘图、位运算等进阶内容。每个案例提供题目描述和源码解析,适合C语言学习者系统练习编程思维和实战能力。从基础控制结构到复杂算法实现,全面培养程序设计能力。
YOLO11多个点组合创新:GC10-DET缺陷检测 | DCNv4结合SPPF+11Detect创新性结合
DCNv4结合SPPF+11Detect创新性结合,原始mAP50为0.633 提升至0.651
C 语言经典100例
C 语言经典100例 C 语言练习实例1 C 语言练习实例2 C 语言练习实例3 C 语言练习实例4 C 语言练习实例5 C 语言练习实例6 C 语言练习实例7 C 语言练习实例8 C 语言练习实例9 C 语言练习实例10 C 语言练习实例11 C 语言练习实例12 C 语言练习实例13 C 语言练习实例14 C 语言练习实例15 C 语言练习实例16 C 语...
Windows部署OpenClaw报错不断?这篇环境配置指南帮你解决难题
想在Windows上部署OpenClaw却频频报错?🔧 本文详细梳理了OpenClaw部署必需环境的安装步骤和官方下载地址 📦,提供完整的验证清单和常见问题排查方法,帮你一次性搞定所有环境配置,顺利部署OpenClaw ✅
LinePhone3.2.7(android端最新版本) sip客户端
SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/
【C语言基础案例】经典C语言程序设计100例附源码解析(91-100例)
本文介绍了5个C语言程序案例(91-95),涵盖时间函数应用和简单系统开发。案例91-93演示了time.h库的使用,包括获取系统时间(91)、计算程序执行时间(92)和精确时钟计时(93)。案例94实现了一个猜数游戏,测试用户反应速度,使用了随机数和时间计算功能。案例95展示了一个家庭财务管理小程序,涉及文件操作、结构体和用户界面设计。这些案例从基础时间处理到实际应用开发,循序渐进地展示了C语言的实用编程技巧。
Devexpress16.2.6破解工具
Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具
经典C语言编程100例——题目+答案代码(完结)
【程序 91】 题目:时间函数举例 1 1.程序分析: 2.程序源代码: #include "stdio.h" #include "time.h" void main() { time_t lt; /*define a longint time varible*/ lt=time(NULL);/*system time and date*/ printf(ctime(<)); /*engli...
IEM模型,地表粗糙度模拟
利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟
计算机控制技术及应用
《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。
c语言经典题目 91-100
分析:先要获取时间戳,然后把时间戳转换成实际时间,再转换成字符串。
C语言经典编程题100例(81~100)
目录81、习题7-7 字符串替换82、习题8-10 输出学生成绩83、习题8-2 在数组中查找指定元素84、习题8-3 数组循环右移85、题8-9 分类统计各类字符个数86、习题9-2 计算两个复数之积87、习题9-6 按等级统计学生成绩88、习题11-1 输出月份英文名89、习题11-2 查找星期90、练习10-1 使用递归函数计算1到n之和91、习题10-2 递归求阶乘和92、习题8-5 使用函数实现字符串部分复制93、习题8-6 删除字符94、习题8-8 判断回文字符串。
菜鸟教程-C语言经典100示例(后50)
注:接上篇(菜鸟教程-C语言经典100示例(前50))51,学习使用按位与 &。52,学习使用按位或 |。53,学习使用按位异或 ^。54,取一个整数a从右端开始的4~7位。55,学习使用按位取反~。56,画图,学用circle画圆形。57,画图,学用line画直线(在TC中实现)。58,学用rectangle画方形。(在TC中实现)。59,画图,综合例子。(在TC中实现)。60,画图,综...
c语言编程题经典100例——(91~95例)
然后,使用循环将整数转换为字符串,每次取余数并将其转换为字符存储到字符串中,最后将字符串返回。这个函数首先检查字符串的第一个字符是否为负号,然后遍历字符串的每一个字符,将其转换为对应的数字,并累加到结果中。这个函数采用简单的加密算法,将输入的数字乘以一个固定的密钥,然后加上一个固定的偏移量。函数中,我们定义了一个输入的数字、一个密钥和一个偏移量,然后使用这些参数调用。函数将加密后的数字减去偏移量,然后除以密钥,返回解密后的数字。函数将输入的数字乘以密钥并加上偏移量,然后返回加密后的数字。
黑马程序员——经典C语言程序设计100例
1.数字排列 2.奖金分配问题 3.已知条件求解整数 4.输入日期判断第几天 5.输入整数进行排序 6.用*号显示字母C的图案 7.显示特殊图案 8.打印九九口诀 9.输出国际象棋棋盘 10.打印楼梯并按条件打印笑脸 11.经典兔子问题 12.判断素数 13.水仙花数问题 14.正整数分解质因数 15.学习成绩划分 16.正整数求其最大公约数和最小公倍数 17.统计英文字母/空格/数...
3万+




被折叠的 条评论
为什么被折叠?



