#include <iostream>
<span>#include <ctime>
</span><span>using namespace std;
</span>int main() {
<span> int n,m;
</span><span> FILE *fpt;
</span><span> cout<<"n = "; cin>>n;
</span><span> fpt=fopen("input.dat","wb");
</span><span> srand(time(NULL));
</span><span>// запись файла
</span><span> for (int i=0; i<n; i++) {
</span><span> m=rand()%8000-3000;
</span><span> cout<<m<<" ";
</span><span> fwrite(&m,sizeof(int),1,fpt);
</span><span> }
</span><span> cout<<endl;
</span><span> fclose(fpt);
</span><span> fpt=fopen("input.dat","rb+");
</span><span> int indf=0,indl=0,vf=0,vl=0,k=0;
</span><span>// чтение файла
</span><span> while (fread(&m,sizeof(int),1,fpt)!=0) {
</span><span> k++;
</span><span> if (!(m%2==0) && (indf==0)) { indf=k-1; vf=m; }
</span><span> if ((!m==0) && (m%2==0)) { indl=k-1; vl=m; }
</span><span> }
</span><span> cout<<"first odd = "<<vf<<" index = "<<indf<<endl;
</span><span> cout<<"last even = "<<vl<<" index = "<<indl<<endl;
</span><span>// обмен первого нечетного и последнего четного
</span><span> if (indf>0) {
</span><span> fseek(fpt,sizeof(int)*indf,SEEK_SET);
</span><span> fwrite(&vl,sizeof(int),1,fpt);
</span><span> }
</span><span> if (indl>0) {
</span><span> fseek(fpt,sizeof(int)*indl,SEEK_SET);
</span><span> fwrite(&vf,sizeof(int),1,fpt);
</span><span> }
</span><span> fclose(fpt);
</span><span> system("pause");
</span><span> return 0;
</span><span>}
</span>n = 6
<span>4368 2733 1112 2620 1941 753
</span><span>first odd = 2733 index = 1
</span><span>last even = 2620 index = 3
</span>
#include <iostream>
#include <cstdlib>
// содержит srand() и rand()
#include <ctime>
using namespace std;
int main()
{
int n=10;
<span> int mas[n] = {};
</span><span> int tmp,j=0;
</span><span> cout<<"random number";
cout<<endl;
</span>// начальная установка генератора случ. чисел
srand(time(NULL));
<span>// заполнение массива случайными числами
</span><span> for (int i = 0; i < n; i++)</span><span>
{
</span><span> mas[i] = rand()/100; cout<<mas[i]<<" ";
</span><span> }</span><span>
cout<<endl;
</span>// перестановка элементов
<span>for (int i = 0; i < n/2; i++)
</span> {<span>
tmp=mas[i];</span><span> mas[i]=mas[2*(i+1)-1];</span><span> j=2*i;
</span> while (j>i)<span>
{</span><span>
mas[j+1]=mas[j];</span><span> j--;
</span><span> }
</span> mas[i+1]=tmp;
<span> }
</span><span>//"массив после замены"
</span><span> for (int i = 0; i < n; i++) </span><span> cout<<mas[i]<<" ";</span><span>
</span><span> cout<<endl;
</span><span> system("pause");
</span><span> return 0;
</span>}
<span>
</span>
<span><span>var n,i,posmax:integer;
max:real;
a:array of real;
<span>begin</span></span></span>
Слово росинка
..............