【数据结构作业】2.12

#include
using namespace std;

typedef struct
{
	int d;
}node;

const int N = 1e5 + 10;
node A[N], B[N];
int len_A, len_B;

void fun(node A[], node B[], int len_A, int len_B)
{
	int flage = 0;
    for(int i = 0; i < len_A && i < len_B; i ++ )
	{
		if(A[i].d == B[i].d)
		continue;
		else
		{
			if(A[i].d < B[i].d)
			flage = -1; 
			else
			flage = 1;
			break;
		}
	}
	
	if(flage == 0)
		if(len_A == len_B)
		printf("A = B");
		else if(len_A > len_B)
		printf("A > B");
		else
		printf("A < B");
	else if(flage == -1)
		printf("A < B");
	else
		printf("A > B");
}

int main()
{
    printf("输入A, B长度:\n");
	cin >> len_A >> len_B;
	
	int d;
	printf("输入A的数据:\n");
	for(int i = 0; i < len_A; i ++ )
	{
		cin >> d;
		A[i].d = d;
	}
	printf("输入B的数据:\n");
	for(int i = 0; i < len_B; i ++ )
	{
		cin >> d;
		B[i].d = d;
	}
    
    fun(A, B, len_A, len_B);
	return 0;
} 

balabalabalabalabalabalabalabalabalabalabalabalabalabala

你可能感兴趣的:(数据结构作业)