ssss.cpp

来自「输入一篇文章,统计各个字出现的次数,希望大家能优化这个程序」· C++ 代码 · 共 71 行

CPP
71 行
字号
#include <iostream.h>
#include <string.h>
#include <malloc.h>
struct Word
{
	char word[10];
	
	Word *next;
};

 Word  *head;
 Word  *create()
 {
   Word  *p=NULL;
   Word  *q=NULL;
  
   head=NULL;
   char danci[10];


    cout<<"请输入你的文章:"<<endl;
    cin>>danci[10];
	while(danci[10]!='$' )
	{
		
		p=new Word;
		strcpy(p->word,danci);
		

		if(head==NULL)
			head=p;
	     else q->next=p;

	      q=p;

		 cin>>danci[10];
	}
	   
	    if(head!=NULL)
	    q->next=NULL;
	     return(head);
     
 }



tongji(Word *head)
{   
	int sum=1;
    Word *temp,*p,*q;
	p=head;
	(p!=NULL)
		p->next=q;
     temp=p;
	
	
   while(p!=NULL&&strcmp(p->word,q->word)!=0)
   {
	   cout<<p;
       
	   q=q->next;
   }

   while(strcmp(head->word,word)==0)
   {

	   sum +=sum;
   cout<<head<<sum;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?