标签:内容 bit pre 文件 fine def 取字符串 ++i cout
输入两个文件名,依次各自读取字符串并比较,如果不同,输出不同处的序号和各自的内容
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define rep(i,a,b) for(int i=a;i<=b;++i) 4 #define ms(arr,a) memset(arr,a,sizeof arr) 5 #define debug(x) cout<<"< "#x" = "<<x<<" >"<<endl 6 int main() 7 { 8 ifstream f1,f2; 9 char f1name[100],f2name[100]; 10 const int maxn=1e5; 11 char s1[maxn],s2[maxn]; 12 cin>>f1name>>f2name; 13 f1.open(f1name);f2.open(f2name); 14 for(int i=1;!f1.eof();++i) 15 { 16 if(f2.eof()) 17 { 18 cout<<f2name<<" is smaller than "<<f1name<<endl; 19 break; 20 } 21 f1>>s1;f2>>s2; 22 if(strcmp(s1,s2))cout<<i<<": "<<s1<<" "<<s2<<endl; 23 } 24 if(!f2.eof())cout<<f1name<<" is smaller than "<<f2name<<endl; 25 }
标签:内容 bit pre 文件 fine def 取字符串 ++i cout
原文地址:https://www.cnblogs.com/maoruimas/p/9550109.html