云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C语言程序设计100个简单的经典例子

C语言程序设计100个简单的经典例子

  • 62 次阅读
  • 3 次下载
  • 2025/6/15 11:21:06

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(\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(\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(\if((strlen(chshop)==0)||(strlen(chmoney)==0)) continue;

if((fp=fopen(\

fprintf(fp,\fputc('\\n',fp); fclose(fp); i++;

gotoxy(41,5+i);

printf(\}}}

============================================================== 【程序96】

题目:计算字符串中子串出现的次数 1.程序分析: 2.程序源代码:

#include \#include \main()

{ char str1[20],str2[20],*p1,*p2; int sum=0;

printf(\scanf(\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(\getch();}

============================================================== 【程序97】

题目:从键盘输入一些字符,逐个把它们送到磁盘上去,直到输入一个#为止。 1.程序分析: 2.程序源代码: #include \main()

{ file *fp;

char ch,filename[10]; scanf(\

if((fp=fopen(filename,\{printf(\exit(0);} ch=getchar(); ch=getchar(); while(ch!='#')

{fputc(ch,fp);putchar(ch); ch=getchar(); }

fclose(fp); }

============================================================== 【程序98】

题目:从键盘输入一个字符串,将小写字母全部转换成大写字母,然后输出到一个磁盘文件“test”中保存。

输入的字符串以!结束。 1.程序分析: 2.程序源代码: #include \main() {file *fp;

char str[100],filename[10]; int i=0;

if((fp=fopen(\{ printf(\exit(0);}

printf(\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(\

fgets(str,strlen(str)+1,fp);

printf(\fclose(fp); }

==============================================================

【程序99】

题目:有两个磁盘文件a和b,各存放一行字母,要求把这两个文件中的信息合并(按字母顺序排列),

输出到一个新文件c中。 1.程序分析: 2.程序源代码: #include \main()

{ file *fp; int i,j,n,ni; char c[160],t,ch;

if((fp=fopen(\

{printf(\exit(0);}

printf(\for(i=0;(ch=fgetc(fp))!=eof;i++) {c[i]=ch;

putchar(c[i]); }

fclose(fp); ni=i;

if((fp=fopen(\

{printf(\exit(0);}

printf(\for(i=0;(ch=fgetc(fp))!=eof;i++) {c[i]=ch;

putchar(c[i]); }

fclose(fp); n=i;

for(i=0;ifor(j=i+1;jif(c[i]>c[j]) {t=c[i];c[i]=c[j];c[j]=t;} printf(\fp=fopen(\

for(i=0;i{ putc(c[i],fp); putchar(c[i]); }

搜索更多关于: C语言程序设计100个简单的经典例子 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

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(\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++

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com