//_2-3
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char str[1000];
int
minlen=1000,i=0,nom[30],j=1;
cout<<"Введите последовательность
слов"<<endl;
cin>>str;
for(;;)
{
while(str[i]!=',')
{
if(str[i]=='.')
break;
i++;
}
nom[j]=i+1;
j++;
if(str[i]=='.')
break;
i++;
}
nom[0]=0;
int a=0,s=0;
for(int
d=1;d<j;d++)
{
if(nom[d]-nom[d-1]<minlen)
{
minlen=nom[d]-nom[d-1];
a=nom[d];s=nom[d-1];
}
}
for(int
q=s;q<a-1;q++)
{
cout<<str[q];
}
cout<< " -cамое короткое
слово его длина : " <<minlen-1<<endl;
getch();
}
|
//_25-1
#include<iostream.h>
#include<conio.h>
void max(double
*t,int n)
{
double m=t[0];
for(int
i=0,j=0;i<n;i++,j++)
{
if(t[i*n+j]>m)
m=t[i*n+j];
}
for(i=n;i!=0;i--)
{
if(t[i*(n-1)]>m)
m=t[i*(n-1)];
}
for(i=0;i<n*n;i++)
{
if(t[i]==m)
t[i]=t[(n*n-1)/2];
}
t[(n*n-1)/2]=m;
}
void main()
{
clrscr();
int n=0,j=0;
double mas[1000];
cout<<"Введите порядок матрицы "<<endl;
cin>>n;
cout<<"Введите матрицу"<<endl;
for(int
i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>mas[i*n+j];
}
}
max(mas,n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<mas[i*n+j]<<endl;
}
}
getch();
}
|
//_26-2
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void
file(FILE*from,FILE*sum,FILE*win)
{
int a[1000];
char s[100];
int b[1000];
for(int
i=0;fscanf(from,"%d%c%d ",&a[i],&s[i],&b[i])!=EOF;i++)
{
cout<<a[i]<<endl;
cout<<s[i]<<endl;
cout<<b[i]<<endl;
if(b[i]>=6&&b[i]<=8)
{
fprintf(sum,"%d%c%d",a[i],s[i],b[i]);
fprintf(sum,"
");
}
if(b[i]==12||b[i]==1||b[i]==2)
{
fprintf(win,"%d%c%d",a[i],s[i],b[i]);
fprintf(win,"
");
}
}
}
void main()
{
clrscr();
FILE*fr;
FILE*sum;
FILE*win;
fr=fopen("c:/in.txt","r");
if(fr==NULL)
cout<<"Cannot
open file"<<endl;
sum=fopen("c:/sum.txt","w+");
if(sum==NULL)
cout<<"Cannot
open file"<<endl;
win=fopen("c:/win.txt","w+");
if(win==NULL)
cout<<"Cannot
open file"<<endl;
file(fr,sum,win);
fclose(fr);
fclose(sum);
fclose(win);
}
|
//_3-2
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void file(FILE*from,FILE*temp,FILE*to)
{
int a[100],b[50];
int
i=0,k=0,j=0,w=0;
while(fscanf(from,"%d",&a[i])!=EOF)
{
if(a[i]>0)
{
k++;
fprintf(temp,"%d",a[i]);
}
if(a[i]<0)
{
b[j]=a[i];
j++;
}
i++;
}
j=0;
i=0;
while(w!=k)
{
w++;
fprintf(to,"%d",a[i]);
fprintf(to,"%d",b[j]);
fprintf(to,"
");
j++;
i++;
}
}
void main()
{
clrscr();
FILE*fr;
FILE*to;
FILE*temp;
fr=fopen("c:/in.txt","r");
if(fr==NULL)
cout<<"Cannot
open file"<<endl;
to=fopen("c:/out.txt","w+");
if(to==NULL)
cout<<"Cannot
open file"<<endl;
temp=fopen("c:/temp.txt","w+");
if(temp==NULL)
cout<<"Cannot
open file"<<endl;
file(fr,temp,to);
fclose(fr);
fclose(temp);
fclose(to);
}
|