C语言编程实例_第1页
C语言编程实例_第2页
C语言编程实例_第3页
C语言编程实例_第4页
C语言编程实例_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 第3章 请你参考前请修改下,或者至少看明白,2#include "string.h"#include "stdio.h"main() char str50; int i,j=0,k=0,length=0; char str150; printf("input words:n"); scanf("%s",str); for(i=0;stri!='0'i+) if(stri>='A' && stri<='Z') str1j=stri; j+;

2、 else if(stri>='a' && stri<='z') str1j=stri-32; j+; length = strlen(str1); for(k=length-1;k>=0;k-) printf("%c",str1k); 截图:4#include "stdio.h"main() int num,i,j,line=0; printf("Enter a number:n"); scanf("%d",&num); if(num<

3、;=1) printf("Please Enter"); return(1); for(i=2;i<num;i+) for(j=2;j<i;j+) if(i/j*j=i) break; if(j=i && i%10!=9) printf("%d,",i); line+; if(line=10) printf("n"); line=0; 截图:7#include "stdio.h"main()int n = 0;int a,b;printf("Enter a number:n&q

4、uot;);scanf("%d",&n);printf("1gt2gt5gn");printf("-n");for(a=0;a<=n;+a) for(b=0;b<=n;+b) if(a+2*b+(n-a-b)*5)=100) printf("%dt%dt%dn",a,b,(n-a-b); 截图: 第4章2#include "stdio.h"main() char * s; char table128; int i; printf("please input a st

5、ring:"); scanf("%s",s); printf("n"); for(i = 0;i < 128;i+) tablei = '0' for(i=0;si!= '0'i+ ) if(si >= 48 && si <=57) | (si >= 65 && si <= 90)| (si >= 97 && si <= 122) tablesi = si; for(i = 0;i < 128;i+) if(table

6、i != '0') printf("%c",tablei); 截图:8#include <stdio.h> void permutation(char a, int m, int n) int i,j; char t; if (m<n-1) permutation(a, m+1, n); for (i=m+1;i<n;i+) t=am; am=ai; ai=t; permutation(a, m+1, n); t=am; am=ai; ai=t; else if(a0>a1&&a1>a2&&

7、a3>a4&&a4>a5&&a0>a3&&a1>a4&&a2>a5) printf("%c%c%cn%c%c%cnn",a0,a1,a2,a3,a4,a5); int main() char a="123456" permutation(a, 0,6); return 0; 截图: 第5章5#include "stdio.h"int fun(char str1100)int i,j=0;for(i=0;str1i!='0'i+

8、) if(str1i='i' && str1i+1='s') | (str1i='I' && str1i+1='S') str1i='b' str1i+1='e' i+; j=1; else str1i=str1i; return j;main() char str100; printf("Enter String :n"); scanf("%s",str); if(fun(str)=0) printf("this s

9、tring not include 'is'"); else printf("%s",str); 截图: C 语言作业#include "stdio.h" main() FILE *fp,*result; char ch='0' char word100020; int count_word1000=0; int i=0,j=0,k=0,flag=2,total=0; float percent; clrscr(); if(fp=fopen("english.txt","r"

10、;)&&(result=fopen("result.txt","w")=NULL) printf("Can't open filen"); printf("Press any key to exit."); getch(); exit(0); printf("nPlease wait."); while(!feof(fp) ch=fgetc(fp); if(ch>='a'&&ch<='z'|ch>='

11、;A'&&ch<='Z') if(ch>='A'&&ch<='Z') ch+=32; flag=0; wordij=ch; j+; else flag+; if(flag=1) total+; wordij='0' count_wordi+; for(k=0;k<i;k+) if(strcmp(wordi,wordk)=0) count_wordk+; count_wordi=0; i-; break; i+; j=0; fprintf(result,"wo

12、rds count percentn"); fprintf(result,"-"); for(k=0;k<i;k+) fprintf(result,"n%-20s",wordk); fprintf(result,"%-10d",count_wordk); percent=100.0*count_wordk/total; fprintf(result,"%.2f%",percent); fprintf(result,"nnThis text has %d word(s).",tot

13、al); fprintf(result,"nAnd here has %d different word(s).",i); fclose(fp); fclose(result); printf("OK!n"); printf("Press any key to exit."); getch(); printf("Bye bye!"); exit(0); 英语原文:Chinese police shot and killed a knife-wielding man who injured three people

14、and took another hostage in a Carrefour store in the southwestern city of Kunming after a four-hour standoff on Saturday.The hostage, a nurse sent there to treat the injured, was rescued unharmed, a spokesman for the Kunming Municipal Public Security Bureau told reporters. The injured people, includ

15、ing two customers and a salesperson, are being treated at a local hospital. One of them is in critical condition. The 39-year-old man, Lu Zhiwen, was believed to have been disappointed in a love affair, and that's probably why he staged the attack, the spokesman said. "He threatened to kill

16、 the hostage if his girl friend doesn't go to the store to see him," he said. "Police had to shoot and kill him to ensure the hostage safety when the nurse was put in great danger." Lu had criminal record, he said, providing no more details. Police are further investigating the in

17、cident. Witnesses and police said the man wielding a knife went into the French retail outlet at about 9:37 a.m. and suddenly began hacking at customers. He injured three people on the second floor, took another one hostage on the third floor and hid in an office. A female nurse was sent inside the

18、store to treat the injured, police said the man then took the nurse hostage and released the other person he had been holding. The man was shot dead at about 1:30 p.m. The attack took place in the Carrefour store on Longquan Road in the northern suburbs of Kunming, capital of Yunnan Province. Carref

19、our has opened four stores in Kunming since 2002. The Longquan store opened on Sept. 8, 2006 as the fourth outlet in the city. It spans more than 7,000 square meters.Since entering the Chinese market in 1995, Carrefour has opened 118 stores on the Chinese mainland. It employs almost 50,000 people.统计

20、结果:words count percent-chinese 3 0.95%police 5 1.58%shot 2 0.63%and 9 2.84%killed 1 0.32%a 11 3.47%knife 2 0.63%wielding 2 0.63%man 5 1.58%who 1 0.32%injured 5 1.58%three 2 0.63%people 4 1.26%took 4 1.26%another 2 0.63%hostage 6 1.89%in 11 3.47%carrefour 4 1.26%store 5 1.58%the 31 9.78%southwestern

21、1 0.32%city 2 0.63%of 4 1.26%kunming 4 1.26%after 1 0.32%four 2 0.63%hour 1 0.32%standoff 1 0.32%on 6 1.89%saturday 1 0.32%nurse 4 1.26%sent 2 0.63%there 1 0.32%to 8 2.52%treat 2 0.63%was 5 1.58%rescued 1 0.32%unharmed 1 0.32%spokesman 2 0.63%for 1 0.32%municipal 1 0.32%public 1 0.32%security 1 0.32

22、%bureau 1 0.32%told 1 0.32%reporters 1 0.32%including 1 0.32%two 1 0.32%customers 2 0.63%salesperson 1 0.32%are 2 0.63%being 1 0.32%treated 1 0.32%at 4 1.26%local 1 0.32%hospital 1 0.32%one 2 0.63%them 1 0.32%is 1 0.32%critical 1 0.32%condition 1 0.32%year 1 0.32%old 1 0.32%lu 2 0.63%zhiwen 1 0.32%b

23、elieved 1 0.32%have 1 0.32%been 2 0.63%disappointed 1 0.32%love 1 0.32%affair 1 0.32%that 1 0.32%s 1 0.32%probably 1 0.32%why 1 0.32%he 6 1.89%staged 1 0.32%attack 2 0.63%said 5 1.58%threatened 1 0.32%kill 2 0.63%if 1 0.32%his 1 0.32%girl 1 0.32%friend 1 0.32%doesn 1 0.32%t 1 0.32%go 1 0.32%see 1 0.32%him 2 0.63%had 3 0.95%shoot 1 0.32%ensure 1 0.32%safety 1 0.32%when 1 0.32%put 1 0.32%great 1 0.32%danger 1 0.32%criminal 1 0.32%record 1 0.32%providing 1 0.32%no 1 0.32%more 2 0.63%details 1 0.32%further 1

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论