Fatlum Berisha C PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Fatlum Berisha

Ushtrime në
C++

Prishtinë,2012
1).
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main ()
{
double m,x,y,z;
cout<<"Vlera hyr\x89se m=";
cin>>m;
cout<<"P\x89r m="<<m<<" vlera e funksionit jan\x89:\n";
cout<<endl;
x=(m*m)/3-m;
cout<<"\tx=";
cout.width(17);
cout.precision(4);
cout.fill('/');
cout<<x;
cout<<endl;
y=sqrt(x-3)+5;
cout<<"\ty=";
cout.width(17);
cout.precision(5);
cout.fill('+');
cout<<y;
cout<<endl;
z=pow(y,3)+x-m;
cout<<"\tz=";
cout.width(17);
cout.precision(3);
cout.fill('*');
cout<<z;
cout<<endl;
cout<<endl;

return 0;
}
2).
//Programi per llogaritjen e funksionit g qe permban ne brendi shumen
#include <iostream>
using namespace std;
int main()
{
int i,n;
double x,s,g;
cout<<"Vlera hyrese n:";
cin>>n;
cout<<"Vlera hyrese x:";
cin>>x;
g=3;
if(x!=5)
{
s=0;
for(i=2;i<=n;i++)
s=s+(x+i);
g=2*x+4*s;
}
cout<<"\nRezultati g="
<<g
<<"\n";

return 0;
}
3).

//Programet permes te cilit llogaritet funksionet x dhe y


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n,i;
double x,y,s;
cout<<"Vlera e variables x \x89sht\x89 x=";
cin>>x;
cout<<"Vlera e variables n \x89sht\x89 n=";
cin>>n;
s=0;
for(i=1;i<=n+1;i++)
if (i!=4)
s=s+i+2;
y=2*x-3*s;
cout<<"Vlera e funksionit y \x89sht\x89 y="
<<y
<<endl;

return 0;
}
4).

//Programi permes te cilit llogaritet qe gjen raportin ne mes vlerave hyrse


#include<iostream>
using namespace std;
int main ()
{
int x,y;
double z;
cout<<"Vlera e variables x=";
cin>>x;
cout<<"Vlera e variables y=";
cin>>y;
if (x>=y)
z=2*x+1;
else
if(x<y)
z=x+y;
cout<<"Funksioni z="
<<z
<<endl;
return 0;
}
5).

//Programi permse te cilit numerohen antaret pozitiv dhe negativ te vektorit


#include<iostream>
using namespace std;
int main()
{
const int m=7;
int A[m]={6,-2,-9,4,7,3,-5};
int i,n,p;
p=0,n=0;
for (i=0;i<m;i++)
if(A[i]>0)
p=p+1;
else
n=n+1;

cout<<"Numri i antarve negativ n="


<<n
<<endl;
cout<<"Numri i antarve pozitiv p="
<<p
<<endl;

return 0;
}
6).
#include<iostream>
#include<math.h>
using namespace std;
int main ()

{
double x,y;
cout<<"Ipet vlera e x=";
cin>>x;
if(x<1.5)
y=5*x+4;
else
if(x<2.7)
y=x-3;
else
if(x<4)
y=5;
else
if(x>4)
y=2*x;
cout<<"Per x="<<x<<" Funksioni ka vlren y="
<<y
<<endl;

return 0;
}
7).
#include<iostream>
using namespace std;
int main ()
{
int i,k;
double s,p,x,n,m,y;
cout<<"Jepet vlera e x=";
cin>>x;
cout<<endl;
cout<<"Jepet vlera e m=";
cin>>m;
cout<<endl;
cout<<"Jepet vlera e n=";
cin>>n;
cout<<endl;
s=0;
for(i=1;i<=m+n;i=i+2)
s=s+(2*i+n);
cout<<"Vlera e shumes eshte s="
<<s
<<endl;
p=1;
for(k=2;k<=n;k++)
p=p*(k+x);
cout<<"Vlera e prodhimit eshte p="
<<p
<<endl;
y=x/2+3*s-2*p;
cout<<"Vlera e funksionit eshte y="
<<y
<<endl;
return 0;
}
8).
#include<iostream>
using namespace std;
int main ()
{
int i,k;
double x,n,y,s,F;
cout<<"Vlera e x=";
cin>>x;
cout<<"Vlera e n=";
cin>>n;
F=1;
for(k=1;k<=n+2;k++)
F=F*k;
cout<<"Faktorieli i llogaritur eshte F="
<<F
<<endl;
s=0;
for (i=1;i<=n;i++)
s=s+(F+i/3);
cout<<"Shuma e llogaritur s="
<<s
<<endl;
y=3*x-2*s;
cout<<"Vlera e funksionit y="
<<y
<<endl;
return 0;
}
9).

#include<iostream>
using namespace std;
int main ()
{
int i;
double n,x,y,p,F,k;
cout<<"Vlera e x=";
cin>>x;
cout<<"Vlera e n=";
cin>>n;
p=1;
for(i=1;i<=n;i++)
if((i==2)||(i==3))
{
}
else
{
F=1;
for(k=1;k<=i+1;k++)
F=F*k;

cout<<"Vlera e Faktorielit eshte F="


<<F
<<endl;
}
p=p*(F+i/3);
cout<<"Vlera e prodhimit eshte p="
<<p
<<endl;
y=3*x+2*p;
cout<<"Vlera e funksionit y="
<<y
<<endl;

return 0;
}

10).

#include<iostream>

using namespace std;

int main ()
{ const int m=5;
int i,A[m];
double a,g,x;
for (i=0;i<m;i++)
{
cout<<"A["<<i<<"]=";
cin>>A[i];
}
cout<<"A={";
for (i=0;i<m;i++)
{
cout<<A[i];
if(i<m-1)
cout<<",";
}
cout<<"}";
a=A[0];
for (i=0;i<m;i++)
if (A[i]>a)
a=A[i];
cout<<endl;
cout<<"Antari me i madh i vektorit a="
<<a
<<endl;
cout<<"Vlera e x=";
cin>>x;
if (x>=5)
g=3*x+a;
else
g=x-1;
cout<<"Vlera e Funksionit g="
<<g
<<endl;
return 0;}
11).
#include <iostream>
using namespace std;
void Rinia(int M[],int m);
int main()
{
const int n=6;
int Moshat[n]={22,28,24,29,18,42};
Rinia(Moshat,n);
system("Pause");
return 0;
}
void Rinia(int M[],int m)
{
int b,i,j;
for(i=0;i<m-1;i++)//5
for(j=i+1;j<m;j++)//5+4+3+2+1=15
if(M[i]>M[j])
{
b=M[i];
M[i]=M[j];
M[j]=b;
}
cout<<"Tri moshat me te reja jane : ";
for(i=0;i<=2;i++)
cout<<M[i]<<" ";
cout<<endl;
}
12).

#include <iostream>

using namespace std;


double MesMosha(int M[],int m);
double DifMosha(int M1[],int m1,int M2[],int m2);
int main()
{
const int m=6;
int Mx[m]={22,28,24,29,18,42},
My[m]={25,21,35,20,49,30};
double d;
d=DifMosha(Mx,m,My,m);
cout<<"Organizata X ka fuqine punetore ";
if(d>0)
cout<<"me te vjeter se organizata";
else if(d==0)
cout<<"te njejte me organizaten";
else
cout<<"me te re se organizata";
cout<< " Y.\n";
system("Pause");
return 0;
}
double DifMosha(int M1[],int m1,int M2[],int m2)
{
double rez;
rez=MesMosha(M1,m1)-MesMosha(M2,m2);
return rez;
}
double MesMosha(int M[],int m)
{
double rez;
int s=0,i;
i=0;
do
{
s=s+M[i];
i++;
}
while (i<m);
rez=(double)s/m;
return rez;
}
13).
#include <iostream>
#include <iomanip>
using namespace std;
const int n=5;
void NdryshoMatricen(int A[][n],double B[][n],int m);
int main()
{
const int m=4;
int A[m][n]={{4,2,7,8,9},{0,12,6,8,2},
{3,5,8,2,1},{14,5,13,8,9}};
double B[m][n];
NdryshoMatricen(A,B,m);
system("Pause");
return 0;
}
void NdryshoMatricen(int A[][n],double B[][n],int m)
{
int i,j;
i=0;
cout<<"Matrica e formuar B:\n\n";
while(i<m)
{
j=0;
while(j<n)
{
if(A[i][j]<10)
B[i][j]=1.15*A[i][j];
else
B[i][j]=0.95*A[i][j];

cout<<setw(7)<<fixed
<<setprecision(2)
<<B[i][j];
/* cout<<B[i][j]<<" ";*/
j++;
}
i++;
cout<<endl;
}
}

14).

#include <iostream>
#include <iomanip>
using namespace std;
void TabelaeShumezimit(int k);
int main()
{
int k;
cout<<"Tabela e shum\x89zimit: ";
cin>>k;
TabelaeShumezimit(k);

system("Pause");
return 0;
}
void TabelaeShumezimit(int k)
{
int i;
cout<<"------------------------------\n";
for(i=1;i<=10;i++)
{
cout<<setw(10)<<i<<" * "<<k
<<" = "<<setw(3)<<i*k<<endl;
}
cout<<"------------------------------\n";
}

15).

//Programi i cili llogarit inverzin e Matrices


#include<iostream>
using namespace std;
int main ()
{
float A[3][3];
float B[3][3];
float C[3][3];
float X[3][3];
int i,j;
float x,n=0;
float a,b,c,d,e,f;
for(i=0;i<3;i++)
{
cout<<endl;
for(j=0;j<3;j++)
{
cout<<"A["<<i<<"]["<<j<<"]=";
cin>>A[i][j];
}
}
cout<<endl<<endl;
cout<<"Matrica A \x89sht\x89"
<<endl;
for(i=0;i<3;i++)
{
cout<<endl;
for(j=0;j<3;j++)
{
cout<<"\tA["<<i<<"]["<<j<<"]="
<<A[i][j];
}
}
cout<<endl<<endl;
cout<<"Determinanta e matrices A\n";
a=A[0][0]*A[1][1]*A[2][2];
b=A[1][0]*A[2][1]*A[0][2];
c=A[0][1]*A[1][2]*A[2][0];

d=A[0][2]*A[1][1]*A[2][0];
e=A[1][2]*A[2][1]*A[0][0];
f=A[0][1]*A[1][0]*A[2][2];

n=a+b+c-(d+e+f);
cout<<"n="
<<n
<<endl;
if(n!=0)
x=1/n;
else
{
cout<<"Nuk Egziston Inverze \n";
cout<<endl;
return 0;
}
cout<<"Matrica e Transponuar e Matrices A"
<<endl;
for(i=0;i<3;i++)
{
cout<<endl;
for(j=0;j<3;j++)
{
B[i][j]=A[j][i];
cout<<"\tB["<<i<<"]["<<j<<"]="
<<B[i][j];
}
}
cout<<endl<<endl;
C[0][0]=B[1][1]*B[2][2]-(B[2][1]*B[1][2]);
C[0][1]=(-1)*(B[1][0]*B[2][2]-(B[2][0]*B[1][2]));
C[0][2]=B[1][0]*B[2][1]-(B[2][0]*B[1][1]);

C[1][0]=(-1)*(B[0][1]*B[2][2]-B[2][1]*B[0][2]);
C[1][1]=B[0][0]*B[2][2]-B[2][0]*B[0][2];
C[1][2]=(-1)*(B[0][0]*B[2][1]-B[2][0]*B[0][1]);

C[2][0]=B[0][1]*B[1][2]-B[1][1]*B[0][2];
C[2][1]=(-1)*(B[0][0]*B[1][2]-B[1][0]*B[0][2]);
C[2][2]=B[0][0]*B[1][1]-B[1][0]*B[0][1];

cout<<"Matrica e Adjunguar e Matrices A te transponuar"


<<endl;
for(i=0;i<3;i++)
{
cout<<endl;
for(j=0;j<3;j++)
{
cout<<"\tC["<<i<<"]["<<j<<"]="
<<C[i][j];
}
}
cout<<endl<<endl;
for(i=0;i<3;i++)
{
cout<<endl;
for(j=0;j<3;j++)
{
X[i][j]=C[i][j]*x;
}
}
cout<<"Matrica inverse e Matrices A\n";
for(i=0;i<3;i++)
{
cout<<endl;
for(j=0;j<3;j++)
{
cout<<"\tX["<<i<<"]["<<j<<"]="
<<X[i][j];
}
}
cout<<endl<<endl;
return 0;}
16).

#include<iostream>
using namespace std;
void VizatoDrejtkendeshin(int m);
int main ()
{
int a;
cout<<"Caktoni diminsionin e katrorit : ";
cin>>a;
VizatoDrejtkendeshin(a);
return 0;
}
void VizatoDrejtkendeshin(int m)
{
char A[30][30];
int i,j;
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
if((i==0)||(i==m-1)||(j==0)||(j==m-1))
A[i][j]='*';
else
A[i][j]=' ';
}
}
for(i=0;i<m;i++)
{
cout<<endl;
for(j=0;j<m;j++)
{
cout<<A[i][j];
}
cout<<" ";
}
cout<<endl<<endl;
}

17).

#include<iostream>
using namespace std;
void LlogaritNoten(int k);
int main ()
{
int f;
cout<<"Piket e Studentiti ne Provim : ";
cin>>f;
cout<<endl<<endl;
cout<<"Piket = ";
cout<<f;
cout<<endl<<endl;
LlogaritNoten(f);
cout<<endl;
return 0;
}
void LlogaritNoten(int k)
{
if(k<50)
cout<<"5";
else
if((k>=50)&&(k<=59))
cout<<"6";
else
if((k>=60)&&(k<=69))
cout<<"7";
else
if((k>=70)&&(k<=79))
cout<<"8";
else
if((k>=80)&&(k<=89))
cout<<"9";
else
if((k>=90)&&(k<=100))
cout<<"10";
else
cout<<" Piket egzistojn deri ne 100";
cout<<endl;
cout<<" Eshte nota e studenti me keto Pike";
cout<<endl;
}

18).
#include<iostream>
using namespace std;
int main ()
{
int const m=17;
char A[m]={'G','j','u','h','e','P','r','o','g','r','a','m','u','e','s','e'};
int i,n;
n=0;
for(i=0;i<m;i++)
{
if(A[i]=='r')
n=n+1;
}
cout<<"Shkronja 'r' eshte perseritur "
<<n
<<endl;
return 0;
}
Provimi Gr.A (23.04.2011) – C++

1).
a) f=7;
b) u=0;
c) v=0;
Detyrat nen b dhe c jane booleane dhe nese eshte e sakt shtyp 1 nese eshte e pasakt shtyp
0;

2).
#include<iostream>
using namespace std;
int main ()
{
int const m=4;
int i,j;
char A[m][m];
int B[m][m];
for(i=0;i<m;i++)
{
cout<<endl;
for(j=0;j<m;j++)
{
if((i==0)||(i==m-1)||(j==0)||(j==m-1))
A[i][j]='+';
else
A[i][j]='-';
cout<<A[i][j];
cout<<" ";
}
}
cout<<endl<<endl;
for(i=0;i<m;i++)
{
cout<<endl;
for(j=0;j<m;j++)
{
if(i>j)
B[i][j]=1;
else
if(i==j)
B[i][j]=0;
else
if(i<j)
B[i][j]=2;
cout<<B[i][j];
cout<<" ";

}
}
cout<<endl<<endl;
return 0;
}

3).
#include<iostream>
using namespace std;
int main ()
{
int const m=4;
int B[m][m]={{3,5,-3,5},
{-5,8,3,2},
{-9,6,-1,4},
{7,8,-3,-2}};
int k,i,j,A[m*m];
k=0;
for(i=0;i<m;i++)
for(j=0;j<m;j++)
{
if(i>j)
if(B[i][j]<0)
{
A[k]=B[i][j];
k=k+1;
}
}
cout<<"A={";
for(i=0;i<k;i++)
{
cout<<A[i];
if(i<k-1)
cout<<",";
}
cout<<"}";
cout<<endl;
return 0;
}

4).
#include<iostream>
using namespace std;
double shuma(int a,int b,int c);
int main ()
{
int n;
double z;
cout<<"n=";
cin>>n;
z=shuma(1,n,2)+2*shuma(2,n,3);
cout<<"Vlera e Funksionit z=";
cout<<z;
cout<<endl;
return 0;
}
double shuma(int a,int b,int c)
{
int i;
double s;
s=0;
for(i=a;i<b;i=i+2)
{
s=s+c*i;
}
return s;
}

5).
#include<iostream>
#include<iomanip>
using namespace std;
void TabelaeShumezimit(int k);
int main ()
{
int f;
cout<<"Tabela e shumezimit me : ";
cin>>f;
TabelaeShumezimit(f);
return 0;
}
void TabelaeShumezimit(int k)
{
int i;
cout<<"---------------------------"
<<endl;
for(i=1;i<=10;i++)
{
cout<<setw(10)<<i<<" * "<<k<<" = "<<setw(3)<<i*k;
cout<<endl;
}
cout<<"---------------------------"
<<endl;
}
Provimi Gr.B (13.06.2011) - C++

1).
a) d=0;
b) e=0;
c) f=5;
Detyrat nen b dhe c jane booleane dhe nese eshte e sakt shtyp 1 nese eshte e pasakt shtyp
0;
2).
#include<iostream>
using namespace std;
int main ()
{
int const m=4;
int i,j;
int A[m][m],B[m][m];
for(i=0;i<m;i++)
{
cout<<endl;
for(j=0;j<m;j++)
{
if((i==0)||(i==m-1)||(j==0)||(j==m-1))
A[i][j]=1;
else
A[i][j]=0;
cout<<A[i][j];
cout<<" ";
}
}
cout<<endl<<endl;
for(i=0;i<m;i++)
{
cout<<endl;
for(j=0;j<m;j++)
{
if(i<j)
B[i][j]=1;
else
if(i==j)
B[i][j]=0;
else
if((i>0)&&(j==0))
B[i][j]=4;
else
if((i>1)&&(j==1))
B[i][j]=5;
else
B[i][j]=6;
cout<<B[i][j];
cout<<" ";
}
}
cout<<endl<<endl;
return 0;}
3).

#include<iostream>
using namespace std;
int main ()
{
int const m=4;
int i,j,k,B[m*m];
int A[m][m]={{3,5,-3,5},
{-5,8,3,2},
{-9,6,-1,4},
{7,8,-3,-2}};
k=0;
for(i=0;i<m;i++)
for(j=0;j<m;j++)
{
if(i<j)
if(A[i][j]>0)
{
B[k]=A[i][j];
k=k+1;
}
}
cout<<"B={";
for(i=0;i<k;i++)
{
cout<<B[i];
if(i<k-1)
cout<<",";
}
cout<<"}";
cout<<endl;
return 0;
}

4).
#include <iostream>
#include <iomanip>
using namespace std;
double SERIA(bool x,int n);
int main()
{
int n;
double z,v;
cout<<"Cakto n:";
cin>>n;
z=SERIA(true,n);
v=SERIA(false,n);
cout<<"z="<<z<<", v="<<v<<endl;
system("Pause");
return 0;
}
double SERIA(bool x,int n)
{
double rez; int i;
if(x)
rez=0;
else
rez=1;
for(i=1;i<=n;i++)
if(x)
rez=rez+i;
else
rez=rez*i;
return rez;
}

5).
#include<iostream>
using namespace std;
double Gama(int a,int b,int c,int d);
double Delta(int k);
int main ()
{
int x,n;
double g;
cout<<"Shtypet vlera e x=";
cin>>x;
cout<<endl;
cout<<"Shtypet vlera e n=";
cin>>n;
cout<<endl;
g=2*x+Delta(n+2)/Delta(6)+2*Gama(1,n,3,1);
cout<<"Vlera e Funksionit g=";
cout<<g<<endl<<endl;
return 0;
}
double Gama(int a,int b,int c,int d)
{
int i;
double S;
S=0;
for(i=a;i<b;i++)
{
S=S+(3*i+d);
}
return S;
}
double Delta(int k)
{
int i;
double F;
F=1;
for(i=1;i<k;i++)
{
F=F*i;
}
return F;
}
Provimi Gr.C (25.01.2010) - C++

1).
a) f=0;
b) g=0;
c) h=9;
Detyrat nen b dhe c jane booleane dhe nese eshte e sakt shtyp 1 nese eshte e pasakt shtyp
0;

2).

a)
Rezultati h= 10;

b)
i=2 x=2 z=11
i=3 x=2 z=12
i=4 x=10 z=10

3).

#include<iostream>
using namespace std;
int main ()
{
int const m=4,n=4;
int B[m][n]={{3,5,-3,5},
{-5,8,3,2},
{-9,6,-1,4},
{7,8,-3,-2}};
int k,i,j,Z[m*n];
k=0;
for(i=0;i<m;i++)
for(j=0;j<m;j++)
{
if((B[i][j]>0)&&(B[i][j]<6))
{
Z[k]=B[i][j];
k=k+1;
}
}
cout<<"Z={";
for(i=0;i<k;i++)
{
cout<<Z[i];
if(i<k-1)
cout<<",";
}
cout<<"}";
cout<<endl;
return 0;
}
4).

#include<iostream>
using namespace std;
double Shuma(int a,int b,int c,int d);
double Fakt(int k);
int main ()
{
int x,n;
double g;
cout<<"Shtypet vlera e x=";
cin>>x;
cout<<endl;
cout<<"Shtypet vlera e n=";
cin>>n;
cout<<endl;
g=x/Fakt(3)+(2*n+1)+3*Shuma(1,n+1,2,3);
cout<<"Vlera e funksionit eshte g="
<<g<<endl<<endl;
return 0;
}
double Shuma(int a,int b,int c,int d)
{
int i;
double s;
s=0;
for(i=a;i<b;i++)
{
s=s+(2*i-d);
}
return s;
}
double Fakt(int k)
{
int i;
double F;
F=1;
for(i=1;i<k;i++)
{
F=F*i;
}
return F;
}

5).

#include<iostream>
using namespace std;
void Suksesi(int k);
int main ()
{
int f;
cout<<"Ju lutem shtypeni vleren per noten e nxenseit : ";
cin>>f;
cout<<endl<<endl;
cout<<"Nota = ";
cout<<f;
cout<<endl<<endl;
Suksesi(f);
return 0;
}
void Suksesi(int k)
{
int i;
cout<<"Vlersimi i notes se nxenesit : ";

if(k==1)
cout<<"Dobet";
else
if(k==2)
cout<<"Mjaftueshem";
else
if(k==3)
cout<<"Mire";
else
if(k==4)
cout<<"Shume mire";
else
if(k==5)
cout<<"Shkelqyeshem";
else
cout<<"Nuk egziston kjo note";

cout<<endl;
}
Provimi Gr.A (Janar.2011) – C++

1).
a) t=1;
b) f=1;
c) g=7;
Detyrat nen a dhe b jane booleane dhe nese eshte e sakt shtyp 1 nese eshte e pasakt
shtyp 0;
2).

a)
Rezultati g= 7.5

b)
i=2 x=7 d=8
i=3 x=13 d=17
i=4 x=21 d=30

3).

#include<iostream>
using namespace std;
int main ()
{
int i,n,k;
const int m=5;
int B[m]={5,-4,6,8,-9};
int A[m];
k=0;
n=0;
for(i=0;i<m;i++)
{
if(B[i]>0)
if(B[i]<7)
{

A[k]=B[i];
k=k+1;
}
}
cout<<"A={";
for(i=0;i<k;i++)
{
cout<<A[i];
if(i<k-1)
cout<<",";
}
cout<<"}";
cout<<endl;
for(i=0;i<m;i++)
{
if(B[i]>0)
n=n+1;
}
cout<<"Numri i antareve pozitiv eshte n="
<<n
<<endl;
return 0;
}

4).

#include<iostream>
using namespace std;
double Alfa(int a,int b,int c,int d);
double Beta(int k);
int main ()
{
int n;
double z;
cout<<"Vlera e n=";
cin>>n;
z=Beta(5)/4+Beta(n+2)-3*Alfa(2,n+2,2,-1);
cout<<"Vlera e funksionit z="
<<z
<<endl;
return 0;
}
double Alfa(int a,int b,int c,int d)
{
int i;
double s;
s=0;
for(i=a;i<b;i++)
{
s=s+(c*i+d);
}
return s;
}
double Beta(int k)
{
int i;
double F;
F=1;
for(i=1;i<k;i++)
{
F=F*i;
}
return F;
}

5).

#include<iostream>
using namespace std;
void LlogaritNoten(int k);
int main ()
{
int f;
cout<<"Piket e Studentiti ne Provim : ";
cin>>f;
cout<<endl<<endl;
cout<<"Piket = ";
cout<<f;
cout<<endl<<endl;
LlogaritNoten(f);
cout<<endl;
return 0;
}
void LlogaritNoten(int k)
{
if(k<50)
cout<<"5";
else
if((k>=50)&&(k<=59))
cout<<"6";
else
if((k>=60)&&(k<=69))
cout<<"7";
else
if((k>=70)&&(k<=79))
cout<<"8";
else
if((k>=80)&&(k<=89))
cout<<"9";
else
if((k>=90)&&(k<=100))
cout<<"10";
else
cout<<" Piket egzistojn deri ne 100";
cout<<endl;
cout<<" Eshte nota e studenti me keto Pike";
cout<<endl;
}
Provimi Gr.D (Janar.2011) – C++

1).
a) f=1;
b) t=1;
c) z=3;
Detyrat nen a dhe b jane booleane dhe nese eshte e sakt shtyp 1 nese eshte e pasakt shtyp
0;
2).

a)
Rezultati g= 9

b)
i=3 x=10 z=5
i=5 x=11 z=11
i=7 x=12 z=13

3).

#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
const int m=5;
int i,k,G[m];
int B[m]={-3,-20,-10,-2,8};
k=0;
for(i=0;i<m;i++)
{

if((abs(B[i])>6)&&(B[i]<0))
{
G[k]=B[i];
k=k+1;
}
}
cout<<"G={";
for(i=0;i<k;i++)
{
cout<<G[i];
if(i<k-1)
cout<<",";

}
cout<<"}"
<<endl;
return 0;
}
4).
#include<iostream>
using namespace std;
double Shuma(int a,int b,int c,int d);
double Fakt(int k);
int main ()
{
int x,n;
double g;
cout<<"Vlera e x=";
cin>>x;
cout<<"Vlera e n=";
cin>>n;
g=5*x+Fakt(n+2)/Fakt(4)+3*Shuma(2,n,3,1);
cout<<"Vlera e funksionit g="
<<g
<<endl;
return 0;
}
double Shuma(int a,int b,int c,int d)
{
int i;
double s;
s=0;
for(i=a;i<b;i++)
{
s=s+(c*i+d);
}
return s;
}
double Fakt(int k)
{
int i;
double F;
F=1;
for(i=1;i<k;i++)
{
F=F*i;
}
return F;
}

5).

#include<iostream>
using namespace std;
void VizatoDrejtkendeshin(int m);
int main ()
{
int a;
cout<<"Caktoni diminsionin e katrorit : ";
cin>>a;
VizatoDrejtkendeshin(a);
return 0;
}
void VizatoDrejtkendeshin(int m)
{
char A[30][30];
int i,j;
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
if((i==0)||(i==m-1)||(j==0)||(j==m-1))
A[i][j]='*';
else
A[i][j]=' ';
}
}
for(i=0;i<m;i++)
{
cout<<endl;
for(j=0;j<m;j++)
{
cout<<A[i][j];
}
cout<<" ";
}
cout<<endl<<endl;
}
19).
#include<iostream>
using namespace std;
void Max(int a,int b,int c);
void Min(int a,int b,int c);
int main ()
{
int X1,X2,X3;
cout<<"Vlera e X1=";
cin>>X1;
cout<<"Vlera e X2=";
cin>>X2;
cout<<"Vlera e X3=";
cin>>X3;
cout<<"Vlera maksimale eshte : ";
Max(X1,X2,X3);
cout<<endl;
cout<<"Vlera minimale eshte : ";
Min(X1,X2,X3);
cout<<endl;
return 0;
}
void Max(int a,int b,int c)
{
if((a>b)&&(b>c))
cout<<a;
else
if((b>a)&&(a>c))
cout<<b;
else
cout<<c;
}
void Min(int a,int b,int c)
{
if((a<b)&&(b<c))
cout<<a;
else
if((b<a)&&(a<c))
cout<<b;
else
cout<<c;
}

You might also like