Untitled

 avatar
unknown
plain_text
4 years ago
1.2 kB
6
Indexable
using namespace std;
#include <iostream>
#include <stdio.h>
#include <conio.h>

int main() {
	setlocale(0, "");
	cout << "Lr9, Timofeev Kirill, gr.6161, var, 13\n***\n";
	char input[100];
	cout << "Введите строку> ";
	gets_s(input);
	int index_x=-1, index_y=-1;
	for (int i = 0; i < 100; i++) {
		if (input[i] == 'x' && index_x == -1) {
			index_x = i;
		}
		if (input[i] == 'y' && index_y == -1) {
			index_y = i;
		}
	}
	if (index_x == -1 && index_y == -1) {
		cout << "x, y отсутствует в строке";
	}
	if (index_x == -1 && index_y != -1) {
		cout << "х отстутствует в строке, y встречается раньше";
	}
	if (index_x != -1 && index_y == -1) {
		cout << "у отстутствует в строке, х встречается раньше";
	}
	if (index_x != -1 && index_y != -1) {
		if (index_x < index_y) {
			cout << "x встречается раньше у";
		}
		else if (index_x > index_y) {
			cout << "y встречается раньше x";
		}
	}
	cout << "\n-------------------------" << endl;
	cout << " press any key";
	//getch();
	
}
Editor is loading...