1. 程式人生 > >##英語文字的單詞統計 排序並輸出前5%

##英語文字的單詞統計 排序並輸出前5%

                             ##  英語文字的單詞統計 排序並輸出前5%
/*
      統計英語文字英語個數及150%*****************************************************
*/

/*
/*#include<iostream>
#include<string>
#include<fstream>
using namespace std;

struct L//建立結構體L
{
	string s;//儲存字串(單詞)
	int data;//單詞在文字中出現的次數
	int flag;//狀態標誌
};

int main()
{
	char s1;//字元操作
	
	string s;//字串操作
	
	L *p,l1;
	p=new L[1000];//建立字串組
	int f,i=0,l,i1;
	ifstream in("C:\\Users\\admin\\Desktop\\data.txt");  //文字輸出
    ofstream out("C:\\Users\\admin\\Desktop\\data1.txt");//文字輸入
	if(!in) {cout<<"不能開啟檔案";}
	in>>noskipws;//輸出空白符 保持data文字中的狀態
	
	while(in>>s1)//單個字元輸出
	{
        if(s1<='z'&&s1>='a'||s1==' ') out<<s1;     //除字母和空白符都不輸入data1,且將大寫字母轉化為小寫
		else if(s1<='Z'&&s1>='A') s1=s1+32,out<<s1;//(將字母和空白輸入data1),排除data中標點符號和其他字元的干擾
		
	}
	
	in.close();                          //關閉文字data
	out.close();                         //關閉文字data1
    
	ifstream ini("C:\\Users\\admin\\Desktop\\data1.txt");//文字輸出對data1進行操作
	while(ini>>s)                                        //單個字串輸出(單個單詞輸出)
	{   
		p[i].s=s;p[i].flag=1;p[i].data=1;//p[i]初始化,通過檔案輸出流獲取單詞賦給p[i].s, 沒有訪問過的標誌符設為1,data為1;
		//a[i]=l;
		i++;
	}
	
    for(int j=0;j<i-1;j++)//查詢各單詞個數
	{
		for( l=j+1;l<i;l++)//每次取一個單詞與後面單詞進行比較,若相同則打data加1,且將相同單詞flag置0,(演算法原理與選擇排序相似)
		{
			if(p[l].flag==0) l++;
			//i1=p[j].s.compare(p[l].s);
			if(p[j].s==p[l].s) p[j].data+=1,p[l].flag=0;
		}
		if(p[j].flag==0) j++;
	}

	for(j=0,l=0;j<i-1;j++)//選擇排序進行排序
	{
		for(l=j+1;l<i;l++)
		{
			if(p[l].flag==0) l++;
			if(p[j].data<p[l].data) l1=p[j],p[j]=p[l],p[l]=l1;
		}
        if(p[j].flag==0) j++;
	}
    ofstream out1("C:\\Users\\admin\\Desktop\\data9.txt");
	out1<<"輸出英語文字中前5%英語單詞及個數為:"<<endl;

	for(j=0,l=0,f=0;j<i&&f<i*0.05;j++)//將排好序的單詞及個數輸入文字文件
	{
		
		if(p[j].flag==1&&p[j].data>=2)
		l+=p[j].data, out1<<p[j].s<<'\t'<<p[j].data<<'\t'<<endl,f++;
	}

	out1<<"U= "<<l<<endl;

	in.close();
	delete []p;
    return 0;
}*/

匯入文字data

Motivation is a skill that we all possess but few of us ever really use. There are times in our lives when we are able to motivate ourselves to overcome almost any difficulty. However, there are also times when it seems like we can’t even motivate ourselves to overcome even the smallest difficulty. What is the secret for mastering your own motivation?First, find out what makes you want to achieve anything in life. When you have a firm understanding of what drives you to accomplish your goals, you will know how to motivate yourself. Whether the drive comes from finding comfort or from feeling like you have control over your life, it is wise to have a firm understanding of yourself and your values.We each have our own ideas about what is important in our lives. Some people think that money is the answer to everything, so they live their lives and make their decisions based on money. Other people may want to become an important part of their society, so this drives them to achieve whatever they want in their

lives.In my dual profession as an educator and health care provider, I have worked with numerous children infected with the virus that causes AIDS. The relationships that I have had with these special kids have been gifts in my life. They have taught me so many things, but I have especially learned that great courage can be found in the smallest of packages. Let me tell you about Tyler.

Tyler was born infected with HIV: his mother was also infected. From the very beginning of his life, he was dependent on medications to enable him to survive. When he was five, he had a tube surgically inserted in a vein in his chest. This tube was connected to a pump, which he carried in a small backpack on his back. Medications were hooked up to this pump and were continuously supplied through this tube to his bloodstream. At times, he also needed supplemented oxygen to support his breathing.

Tyler wasn’t willing to give up one single moment of his childhood to this deadly disease. It was not unusual to find him playing and racing around his backyard, wearing his medicine-laden backpack and dragging his tank of oxygen behind him in his little wagon. All of us who knew Tyler marveled at his pure joy in being alive and the energy it gave him. Tyler’s mom often teased him by telling him that he moved so fast she needed to dress him in red. That way, when she peered through the window to check on him playing in the yard, she could quickly spot him.

This dreaded disease eventually wore down even the likes of a little dynamo like Tyler. He grew quite ill and, unfortunately, so did his HIV-infected mother. When it became apparent that he wasn’t going to survive, Tyler’s mom talked to him about death. She comforted him by telling Tyler that she was dying too, and that she would be with him soon in heaven.

A few days before his death, Tyler beckoned me over to his hospital bed and whispered, “I might die soon. I’m not scared. When I die, please dress me in red. Mom promised she’s coming to heaven, too. I’ll be playing when she gets there, and I want to make sure she can find me.”

匯出文字data1

motivation is a skill that we all possess but few of us ever really use there are times in our lives when we are able to motivate ourselves to overcome almost any difficulty however there are also times when it seems like we cant even motivate ourselves to overcome even the smallest difficulty what is the secret for mastering your own motivationfirst find out what makes you want to achieve anything in life when you have a firm understanding of what drives you to accomplish your goals you will know how to motivate yourself whether the drive comes from finding comfort or from feeling like you have control over your life it is wise to have a firm understanding of yourself and your valueswe each have our own ideas about what is important in our lives some people think that money is the answer to everything so they live their lives and make their decisions based on money other people may want to become an important part of their society so this drives them to achieve whatever they want in their livesin my dual profession as an educator and health care provider i have worked with numerous children infected with the virus that causes aids the relationships that i have had with these special kids have been gifts in my life they have taught me so many things but i have especially learned that great courage can be found in the smallest of packages let me tell you about tylertyler was born infected with hiv his mother was also infected from the very beginning of his life he was dependent on medications to enable him to survive when he was five he had a tube surgically inserted in a vein in his chest this tube was connected to a pump which he carried in a small backpack on his back medications were hooked up to this pump and were continuously supplied through this tube to his bloodstream at times he also needed supplemented oxygen to support his breathingtyler wasnt willing to give up one single moment of his childhood to this deadly disease it was not unusual to find him playing and racing around his backyard wearing his medicineladen backpack and dragging his tank of oxygen behind him in his little wagon all of us who knew tyler marveled at his pure joy in being alive and the energy it gave him tylers mom often teased him by telling him that he moved so fast she needed to dress him in red that way when she peered through the window to check on him playing in the yard she could quickly spot himthis dreaded disease eventually wore down even the likes of a little dynamo like tyler he grew quite ill and unfortunately so did his hivinfected mother when it became apparent that he wasnt going to survive tylers mom talked to him about death she comforted him by telling tyler that she was dying too and that she would be with him soon in heavena few days before his death tyler beckoned me over to his hospital bed and whispered i might die soon im not scared when i die please dress me in red mom promised shes coming to heaven too ill be playing when she gets there and i want to make sure she can find me

匯出文字data9

輸出英語文字中前5%英語單詞及個數為: to 26 in 15 his 15 him 11 the 10 that 10 of 10 have 9 and 9 a 8 when 8 she 8 was 7 you 6 he 6 i 6 so 5 it 5 is 5 with 5 me 5 your 4 their 4 on 4 this 4 tyler 4 want 4 motivate 3 U= 216