Home
О нас
Products
Services
Регистрация
Войти
Поиск
KsyOl
@KsyOl
August 2021
1
58
Report
Даны два массива x(n) и y(n) . В каком из них больше ненулевых элементов? (НА ЯЗЫКЕ С++)
Please enter comments
Please enter your name.
Please enter the correct email address.
Agree to
terms of service
You must agree before submitting.
Send
Answers & Comments
GreenApelsin
#include <iostream>
#include <cstdlib>#include <ctime>
using namespace std;
int main() {
srand(time(0));
const int n = 5;
int x[n], y[n], x0=0, y0=0;
for (int i = 0; i < n; ++i) {
x[i] = rand() % 5;
y[i] = rand() % 5;}
for (int i = 0; i < n; ++i) {
cout<< x[i]<<' ';}
cout << endl;
for (int i = 0; i < n; ++i) {cout << y[i] << ' ';}
for (int i = 0; i < n; ++i) {
if (x[i]) x0++;
if (y[i]) y0++;}
cout << endl;
if (x0 > y0) cout << 'x';
if (x0 < y0) cout << 'y';
if (x0 == y0) cout << '=';
return 0;}
1 votes
Thanks 1
More Questions From This User
See All
KsyOl
August 2022 | 0 Ответы
Дано 2 массива х(n) и у(m). Сколько раз встречается второй элемент второго масси...
Answer
KsyOl
June 2022 | 0 Ответы
Помогите пожалуйста с заданием! Если нетрудно, то с объяснением почему именно та...
Answer
KsyOl
March 2022 | 0 Ответы
(ЯЗЫК С++) Задать файл F, компоненты которого являются целыми числами. Переписат...
Answer
KsyOl
September 2021 | 0 Ответы
Элементы массива стоящие на четных местах, возвести в квадрат, определить их сум...
Answer
рекомендуемые вопросы
rarrrrrrrr
August 2022 | 0 Ответы
о чем должны позаботиться в первую очередь взрослые при организационном вывозе н...
danilarsentev
August 2022 | 0 Ответы
Есть два станка на которых выпускают одинаковые запчасти один производит a запча...
myachina8
August 2022 | 0 Ответы
Найти по графику отношение V3:V1. В ответах написано 9, но нужно решение...
ydpmn7cn6w
August 2022 | 0 Ответы
Choose the correct preposition: 1.I am fond (out,of,from) literature. 2.where ar...
millermilena658
August 2022 | 0 Ответы
Определите Как создавалась и кто создавал арабское государство в крации...
MrZooM222
August 2022 | 0 Ответы
Ч. Айтманов в рассказе "Красное яблоко" использует метод рассказ в рассказе. Опи...
timobila47
August 2022 | 0 Ответы
каково было назначение каждой из частей византийского храма? помогите пожалуйста...
ivanyyaremkiv
August 2022 | 0 Ответы
moment. 6....
Участник Знаний
August 2022 | 0 Ответы
Пожалуйста!!!!!!!!!!!!...
sarvinozwakirjanova
August 2022 | 0 Ответы
помогите пожалусто пж...
×
Report "Даны два массива x(n) и y(n) . В каком из них больше ненулевых элементов? (НА ЯЗ..."
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
Helpful Links
О нас
Политика конфиденциальности
Правила и условия
Copyright
Контакты
Helpful Social
Get monthly updates
Submit
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <cstdlib>#include <ctime>
using namespace std;
int main() {
srand(time(0));
const int n = 5;
int x[n], y[n], x0=0, y0=0;
for (int i = 0; i < n; ++i) {
x[i] = rand() % 5;
y[i] = rand() % 5;}
for (int i = 0; i < n; ++i) {
cout<< x[i]<<' ';}
cout << endl;
for (int i = 0; i < n; ++i) {cout << y[i] << ' ';}
for (int i = 0; i < n; ++i) {
if (x[i]) x0++;
if (y[i]) y0++;}
cout << endl;
if (x0 > y0) cout << 'x';
if (x0 < y0) cout << 'y';
if (x0 == y0) cout << '=';
return 0;}