📄 comparestring.cpp
字号:
#include<iostream>
#include<cstdlib>
#include<string>
#include<iomanip>
using namespace std;
int aa[105],bb[105];
int main()
{
int i,j,k;
int a,b;
void fist(int n,int m);
void second(int a,int b);
void third(int a,int b);
cin>>a;
for(i=0;i<a;i++)
{
cin>>aa[i];
}
cin>>b;
for(i=0;i<b;i++)
{
cin>>bb[i];
}
if(a==b)
{ fist(a,b);
}
else if(a<b){second(a,b);}
else {third(a,b);}
system("PAUSE");
return 0;
}
void fist(int n,int m)
{ int i,k,j=0;
for(i=0;i<n;i++)
{ for(k=0;k<m;k++)
{
if(aa[i]==bb[k])
j++;
}
}
if(n==j) {cout<<"A equals B";}
else if(j==0) {cout<<"A and B are disjoint";}
else cout<<"I'm confused!";
return ;
}
void second(int n,int m)
{ int i,k,j=0;
for(i=0;i<n;i++)
{ for(k=0;k<m;k++)
{
if(aa[i]==bb[k])
j++;
}
}
if(n==j) {cout<<"A is a proper subset of B";}
else if(j==0) {cout<<"A and B are disjoint";}
else cout<<"I'm confused!";
return ;
}
void third(int n,int m)
{ int i,k,j=0;
for(i=0;i<m;i++)
{ for(k=0;k<n;k++)
{
if(bb[i]==aa[k])
j++;
}
}
if(m==j) {cout<<"B is a proper subset of A";}
else if(j==0) {cout<<"A and B are disjoint";}
else cout<<"I'm confused!";
return ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -