Home
О нас
Products
Services
Регистрация
Войти
Поиск
ЛЕРКА1ЗАЙКА
@ЛЕРКА1ЗАЙКА
August 2022
1
6
Report
ПОМОГИТЕ ОЧЕНЬ НАДО
в одномерном массиве элементы которого целые числа вставить новый элемент перед первым отрицательным элементом
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
Gleb1Kosyrev
Verified answer
//Dev-C++ (C)
#include <stdio.h>
#define n 5
int main(void)
{int Array[n],NewEle,point,boo;
point=-1;
boo=1;
for(int i=0;i<n-1;i++)
{scanf("%d",&Array[i]);
if((Array[i]<0)&&(boo)){
point=i;
boo=0;}
}
if(point==-1) printf("No negative elements");
else
{scanf("%d",&NewEle);
for(int i=n-2;i>=point;i--)
Array[i+1]=Array[i];
Array[point]=NewEle;
for(int i=0;i<n;i++)
printf("%d ",Array[i]);}
return 0;}
Пример ввода:
1
-2
3
4
5
Пример вывода:
1 5 -2 3 4
1 votes
Thanks 0
×
Report "ПОМОГИТЕ ОЧЕНЬ НАДО в одномерном массиве элементы которого целые числа вставить ..."
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
Verified answer
//Dev-C++ (C)#include <stdio.h>
#define n 5
int main(void)
{int Array[n],NewEle,point,boo;
point=-1;
boo=1;
for(int i=0;i<n-1;i++)
{scanf("%d",&Array[i]);
if((Array[i]<0)&&(boo)){
point=i;
boo=0;}
}
if(point==-1) printf("No negative elements");
else
{scanf("%d",&NewEle);
for(int i=n-2;i>=point;i--)
Array[i+1]=Array[i];
Array[point]=NewEle;
for(int i=0;i<n;i++)
printf("%d ",Array[i]);}
return 0;}
Пример ввода:
1
-2
3
4
5
Пример вывода:
1 5 -2 3 4