求高手帮忙看看这个程序,《小弟新手》
c++吧
全部回复
仅看楼主
level 1
09毕飞鸟 楼主
# include <iostream>
# include <cstring>
# include <fstream>
using main()
{
     char C;
     ifstream infile ("奥巴马演讲稿.txt")
     ofstream outfile ("复制文本.txt")
     if(!infile ||!outfile)
     {
         cout<<"文件打开失败!"<<endl;
         return 1;
     }
     int k=0;
     char A[20000];
     while (!infile.eof())
     {
         infile get(c);
         outfile put(c);
         A[k]=C;
         k++;
     }
     infile close();
     outfile close();
     A[k+1]='\0';
     ofstream outfile 2 ("文件倒序.txt");
     if(!outfile 2)
     {
         cout<<"文件打开失败!"<<endl;
         return 1;
     }
     for(int P=k;P>=0;p--)
     {
         outfile 2<<A[p];
     }
     outfile 2 close ();
     char * word [5000];
     int j=0;
     int count=0;
     for(int t=0;t<strlen(A);t++)
     {
         if(A[t]>='A'&&A[t]<='Z')
         {
             A[t]=A[t]
+3
2;
         }
     }
     for(int i=0;i<strlen(A);i++)
     {
         if(A[i]>='a'&&A[i]<='Z')
         {
             if(i==strlen(A)-1)
             {
                 word[count]=new char[20];
                 for(int k=j;k<=i;k++)
                 {
                     word[count][k-j]=A[k];

2010年11月18日 11点11分 1
level 1
09毕飞鸟 楼主
                 }
                 word[count][i+1-j]='\0';
                 count ++;
                 break;
             }
             continue;
         }else
         {
             if(j<i)
             {
                 word[count]=new char [20];
                 for(int k=j;k<i;k++)
                 {
                     word[count][i-j]='\0';
                     count ++;
                 }
                 j=i+1;
             }
         }
         ofstream   outfile 3("单词数.txt");
         if(!outfile 3)
         {
             cout<<"文件打开失败!"<<endl;
             return 1;
         }
         outfile 3<<"单词数为:"<<count<<endl;
         outfile 3 close();
         int M[5000];
         int num[5000];
         for (int l=0;l<count;l++)
         {
             M[l]=1;
         }
         for(int a=0;a<count;a++)
         {
             num[a]=M[a];

2010年11月18日 11点11分 2
level 1
09毕飞鸟 楼主
             for(int b=a+1;b<count;b++)
             {
                 if(strcmp (word[a],word[b])==0)
                 {
                     num[a]=num[a]+M[b];
                     M[b]=0;
                 }
             }
         }
         ofstream outfile 4("前十个高频词.txt");
         if(!outfile 4)
         {
             cout<<"文件打开失败!"<<endl;
             return 1;
         }
         for(int n=1;n<=10;n++)
         {
             int max=0;
             for   (int c=1;c<count;c++)
             {
                 if(num[c]>=num[max])
                 {
                     max=c;
                 }
             }
             outfile 4<<"第"<<n<<"高频词是"<<word[max]<<"出现了"<<num[max]<<"次"<<endl;
             num[max]=0;
         }
         outfile 4 close ();
         for(i=0;i<count;i++)
         {
             delete [] word [i];
         }
         return 0;
     }
2010年11月18日 11点11分 3
level 1
09毕飞鸟 楼主
为何调试不了啊
2010年11月18日 11点11分 4
level 1
09毕飞鸟 楼主
这不是c++吧!!!!!!!!!!![88]
2010年11月23日 14点11分 5
level 12
outfile 4 close ();
我只是往下拉滚动条时瞟见的
我是说真的
2010年11月23日 23点11分 6
level 11
什么叫调试不了?
2010年11月24日 01点11分 7
1