Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by Leha ( 14 years ago )
// lab7v10.cpp : Defines the entry point for the console application.
//Удалить из  массива все элементы совпадающие с его минимальным значением. 
//Добавить в начало массива 3 элемента с значением равным среднему арифметическому массива.

#include "stdafx.h"
#include "iostream"
#include "time.h"

using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
 srand((unsigned)time(NULL));
 double a[999],min,sum=0;
 int n;
 cin>>n;
 for(int i=0;i<n;i++)
 {
  a[i]=rand();
  cout<<a[i]<<' ';
 }
 min=a[0];
for(int i=0;i<n;i++)
 if(a[i]<min)
  min=a[i];
for(int i=0;i<n;i++)
{
 if(a[i]==min)
 {
  for(int u=i;u<n;u++)a[u]=a[u+1];
 n--;
 i++;
 }
}
cout<<'n';
for(int i=0;i<n;i++)cout<<a[i]<<' ';
cout<<'n';
for(int i=0;i<n;i++)
 sum+=a[i];
sum=sum/n;
for(int i=n+3;i>=3;i--)a[i]=a[i-3];
n+=3;a[0]=sum;
a[1]=sum;a[2]=sum;
for(int i=0;i<n;i++)cout<<a[i]<<' ';
cout<<'n';
 return 0;
}

 

Revise this Paste

Children: 44017 44018
Your Name: Code Language: