满意答案
dong8585
2013.08.24
采纳率:46% 等级:12
已帮助:8852人
#include
#include
#include
#include
using namespace std;
#define Num 12
string target[] = {"void","int","float","double","while","for","do","break","class","char","if","else"};
int rel1[Num] = {0};
int rel2[Num] = {0};
void main()
{
// string name1,name2;
char name1[50],name2[50];
cout<
cin>>name1;
cout<
cin>>name2;
ifstream fin(name1);
if(fin.bad ())
{
cout<
return;
}
ifstream fin2 (name2 );
if(fin2.bad ())
{
cout<
return;
}
string text;
getline(fin,text);
while(!fin.eof ())
{
for(int k= 0 ;k
{
int i = 0;
while(true)
{
i = text.find(target[k],i);
if(i == -1)
break;
i++;
rel1[k]++;
}
}
getline(fin,text);
}
getline(fin2,text);
while(!fin2.eof ())
{
for(int k= 0 ;k
{
int i = 0;
while(true)
{
i = text.find(target[k],i);
if(i == -1)
break;
i++;
rel2[k]++;
}
}
getline(fin2,text);
}
int sum = 0;
for(int i = 0;i
{
sum+=rel1[i]-rel2[i];
}
int s = sqrt(sum);
cout<
}
00分享举报