Varianta 27 bacalaureat informatica 2007

Cerinte si rezolvari


{pdf=pdf/bacalaureat2007/varianta_027.pdf|600|600}
Rezolvari
1)
#include<iostream.h>
int n,i;
void main()
{
cin>>n;
for(i=1;i<=n;i++)
cout<<i*10<<" ";
}
2)
#include<iostream.h>
#include<string.h>
char a[101],b[101];
int n;
int aparitii(char s[101],char x)
{
int ok=0;
for(int i=0;i<strlen(s);i++)
if(s[i]==x)
ok++;
return ok;
}
void main()
{
cin>>a;
cin>>b;
int ok=1;

for(int i=0;i<strlen(a);i++)
if(aparitii(a,a[i])!=aparitii(b,a[i]))
ok=0;

if(ok)
cout<<"anagrame";
else
cout<<"nu sunt anagrame";
}
3)
#include<fstream.h>
ifstream f("bac.txt");
int n,max,min,a,b,i;
void citire()
{
f>>n;
max=0;
min=999;
for(i=1;i<=n;i++)
{
f>>a;
f>>b;
if(a>max)
max=a;
if(b<min)
min=b;
}
if(max>min)
cout<<"multime vida";
else
cout<<max<<" "<<min;
}
void main()
{
citire();
}