Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <std.h>
- #include <conio.h>
- using namespace std;
- int main(){
- setlocale(LC_ALL,"");
- //объявляем
- int a[]={14,15,-9,-581,-145,24,4},b=1,c=0,buffer=0;
- int size = sizeof(a)/sizeof(int);
- for(int i=0;i<size;i+=2){//1
- b*=a[i];//приумножаем
- }
- for(int i=1;i<size-1;i++){//2
- c+=a[i];//приплюсовуем
- }
- for(int i=0;i<size-1;i++){//3
- if(a[i]<0){
- for(int j=1;j+i<size;j++){
- if(a[i+j]>0){//перемещаем
- buffer=a[i+j];
- a[i+j]=a[i];
- a[i]=buffer;
- }
- }
- };
- }
- //выводим
- cout<<"Первый этап: "<<b<<"\nВторой этап: "<<c<<"\nТретий этап: ";
- for(int i=0;i<size;i++) cout<<a[i]<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment