Страница: 3/5
}
//_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);
}
//_3-3 #include<iostream.h> #include<stdio.h> #include<conio.h> void main() { clrscr(); char str[300]; int a=0,b[100],c[100],j=0,i=0,max=0; cout<<"Введитестроку символов "<<endl; for(;;) { cin>>str[i]; if(str[i]=='.') break; i++; } i=0; for(;;i++) { if (str[i]=='.') { c[j]=i; b[j+1]=-1; break; } if (str[i]==',') { c[j]=i; if(a==0) b[j]=0; j++; a=0; continue; } if(str[i]=='a'||str[i]=='i'||str[i]=='e') { a++; b[j]=a; } } for(j=0;b[j]!=-1;j++) { if(b[j]>max) { max=b[j]; i=j; } } if(i==0) c[i-1]=-1; for(int x=c[i-1]+1;x!=c[i];x++) cout<<str[x]; getch(); } |
//_5-2 #include<iostream.h> #include<stdio.h> #include<conio.h> void file(FILE*from,FILE*to) { char f[100]; int i=0; while(fscanf(from,"%c",&f[i])!=EOF) { if(f[i]=='A') fprintf(to,"%c",f[i-1]); i++; } } void main() { clrscr(); FILE*fr; FILE*to; 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; file(fr,to); fclose(fr); fclose(to); } //_4-3 #include<iostream.h> #include<conio.h> #include<string.h> void main() { clrscr(); char str[1000]; int p=0,f=0,t=1; cout<<"Введите последовательность слов"<<endl; cin>>str; for(int i=0;;i++) { if(str[i]=='.'&&p==0) break; if(str[i]=='.') { i=0; p=0; Реферат опубликован: 30/05/2008 |