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

提交評論