好文档 - 专业文书写作范文服务资料分享网站

C语言编程实例100题

天下 分享 时间: 加入收藏 我要投稿 点赞

#i nclude \struct student { int x; char c; } a; main() {a.x=3; a.c='a'; f(a);

printf(\}

f(struct student b) { b.x=20; b.c='y'; }

============================================================== 【程序88】

题目:读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*。 1.程序分析: 2.程序源代码: main() {int i,a,n=1; while(n<=7) { do {

scanf(\ }while(a<1||a>50); for(i=1;i<=a;i++) printf(\printf(\n++;} getch(); }

============================================================== 【程序89】

题目:某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换。 1.程序分析: 2.程序源代码: main() {int a,i,aa[4],t; scanf(\aa[0]=a; aa[1]=a0/10; aa[2]=a00/100; aa[3]=a/1000; for(i=0;i<=3;i++) {aa[i]+=5; aa[i]%=10;

}

for(i=0;i<=3/2;i++) {t=aa[i]; aa[i]=aa[3-i]; aa[3-i]=t; }

for(i=3;i>=0;i--) printf(\}

============================================================== 【程序90】

题目:专升本一题,读结果。 1.程序分析: 2.程序源代码: #i nclude \#define M 5 main()

{int a[M]={1,2,3,4,5}; int i,j,t; i=0;j=M-1; while(i {t=*(a+i); *(a+i)=*(a+j); *(a+j)=t; i++;j--; }

for(i=0;i printf(\}

【程序91】

题目:时间函数举例1 1.程序分析: 2.程序源代码: #i nclude \#i nclude \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*/ #i nclude \#i nclude \main()

{ time_t start,end; int i;

start=time(NULL);

for(i=0;i<3000;i++)

{ printf(\end=time(NULL);

printf(\}

============================================================== 【程序93】

题目:时间函数举例3 1.程序分析: 2.程序源代码:

/*calculate time*/ #i nclude \#i nclude \main()

{ clock_t start,end; int i; double var; start=clock(); for(i=0;i<10000;i++)

{ printf(\end=clock();

printf(\}

============================================================== 【程序94】

题目:时间函数举例4,一个猜数游戏,判断一个人反应快慢。 1.程序分析: 2.程序源代码: #i nclude \#i nclude \#i nclude \main() {char c;

clock_t start,end; time_t a,b; double var; int i,guess; srand(time(NULL));

printf(\loop:

while((c=getchar())=='y') {

i=rand()0;

printf(\start=clock(); a=time(NULL); scanf(\while(guess!=i) {if(guess>i)

{printf(\

scanf(\else

{printf(\scanf(\}

end=clock(); b=time(NULL);

printf(\printf(\if(var<15)

printf(\else if(var<25)

printf(\else

printf(\printf(\printf(\}

printf(\if((c=getch())=='y') goto loop; }

============================================================== 【程序95】

题目:家庭财务管理小程序 1.程序分析: 2.程序源代码:

/*money management system*/ #i nclude \#i nclude \main() { FILE *fp; struct date d; float sum,chm=0.0; int len,i,j=0; int c;

char ch[4]=\ pp: clrscr(); sum=0.0;

gotoxy(1,1);printf(\gotoxy(1,2);printf(\

gotoxy(1,3);printf(\gotoxy(1,4);printf(\gotoxy(1,5);printf(\gotoxy(1,6);printf(\gotoxy(1,7);printf(\gotoxy(1,8);printf(\gotoxy(1,9);printf(\gotoxy(1,10);printf(\

gotoxy(1,11);printf(\gotoxy(1,12);printf(\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,\ for(;;) {

gotoxy(3,24);printf(\gotoxy(13,10);printf(\gotoxy(13,13);printf(\gotoxy(13,7);printf(\j=18;

ch[0]=getch(); if(ch[0]==27) break;

strcpy(chshop,\strcpy(chmoney,\if(ch[0]==9) { mm:i=0;

fp=fopen(\gotoxy(3,24);printf(\

gotoxy(6,4);printf(\

gotoxy(1,5);printf(\gotoxy(41,4);printf(\gotoxy(41,5);printf(\

while(fscanf(fp,\{ if(i==36) { getch(); i=0;}

if ((i6)<17) { gotoxy(4,6+i); printf(\gotoxy(4,6+i);} else if((i6)>16)

C语言编程实例100题

#include\structstudent{intx;charc;}a;main(){a.x=3;a.c='a';f(a);printf(\}f(structstudentb){b.x=20;b.c='y';}===============================================
推荐度:
点击下载文档文档为doc格式
6lg4i0v0jd0weks4q3a5
领取福利

微信扫码领取福利

微信扫码分享