Zgjidhja e Ushtrimeve te Leksionit 10

Një zgjidhje e ushtrimeve të leksionit 10 :

Ushtrimi 1:

#include<stdio.h>
#include<conio.h>
int main(){
int i,j,n,m;
printf(“Jep sa rreshta do kete tabela : “);
scanf(“%d”,&n);
printf(“Jep sa shtylla do kete tabela : “);
scanf(“%d”,&m);
int t[n][m];
for(i=0;i<n;i++)
for(j=0;j<m;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&t[i][j]);
}
for(i=0;i<n;i++){
printf(“\n\n”);
for(j=0;j<m;j++){
t[i][j]=2*(t[i][j]);
printf(“\t%d”,t[i][j]);
}
}
getch();
return 0;
}

____________________________________

Ushtrimi 2:

#include<stdio.h>
#include<conio.h>
const int n=5,m=5;
void njehsimtabele(int t[n][m]){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&t[i][j]);
}
}
void funksion(int a[n][m]){
int shp=0,shn=0,poz=0,neg=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(a[i][j]>0){
shp+=a[i][j];
poz++;
}
else if(a[i][j]<0){
shn+=a[i][j];
neg–;
}
}
}
printf(“\nShuma e numrave pozitive eshte : %d.\n”,shp);
printf(“Sasia e numrave pozitive eshte : %d.\n”,poz);
printf(“Shuma e numrave negative eshte : %d.\n”,shn);
printf(“Sasia e numrave negative eshte : %d.\n”,neg);
}
int main(){
int a[n][m];
njehsimtabele(a);
funksion(a);
getch();
return 0;
}
____________________________________

Ushtrimi 3 :

#include<stdio.h>
#include<conio.h>
const int n=5,m=5;
void njehsimtabele(int t[n][m]){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&t[i][j]);
}
}
void afishimtabele(int t[n][m]){
for(int i=0;i<n;i++){
printf(“\n\n”);
for(int j=0;j<m;j++)printf(“\t%d”,t[i][j]);
}
printf(“\n”);
}
void funksion(int a[n][m]){
for(int j=0;j<m;j++){
int sh=0;
for(int i=0;i<n;i++){
sh=sh+a[i][j];
}
printf(“\nShuma e elementeve te shtylles %d eshte : %d.”,j+1,sh);
}
}
int main(){
int a[n][m];
printf(“Fut elementet e tabeles : \n”);
njehsimtabele(a);
printf(“\nUshtrimi nuk e kerkon afishimin e tabeles.\nE ilustrova qe te keni te lehte kontrollin e saktesise se pergjigjes.”);
afishimtabele(a);
funksion(a);
getch();
return 0;
}

____________________________________

Ushtrimi 4 :

#include<stdio.h>
#include<conio.h>
const int n=5,m=5;
void njehsimtabele(int t[n][m]){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&t[i][j]);
}
}
void afishimtabele(int t[n][m]){
for(int i=0;i<n;i++){
printf(“\n\n”);
for(int j=0;j<m;j++)printf(“\t%d”,t[i][j]);
}
printf(“\n”);
}
void funksion(int a[n][m]){
int min=9999;
for(int i=0;i<n;i++){
int sh=0;
for(int j=0;j<m;j++){
sh=sh+a[i][j];
}
if(sh<min)min=sh;
}
printf(“\nShuma me e vogel eshte %d.”,min);
}
int main(){
int a[n][m];
printf(“Fut elementet e tabeles : \n”);
njehsimtabele(a);
printf(“\nUshtrimi nuk e kerkon afishimin e tabeles.\nE ilustrova qe te keni te lehte kontrollin e saktesise se pergjigjes.”);
afishimtabele(a);
funksion(a);
getch();
return 0;
}

____________________________________

Ushtrimi 5 :

#include<stdio.h>
#include<conio.h>
const int n=5,m=5;
void njehsimtabele(int t[n][m]){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&t[i][j]);
}
}
void afishimtabele(int t[n][m]){
for(int i=0;i<n;i++){
printf(“\n\n”);
for(int j=0;j<m;j++)printf(“\t%d”,t[i][j]);
}
printf(“\n”);
}
void funksion(int a[n][m]){
int max,pozi,pozj;
for(int i=0;i<n;i++){
max=-9999;
for(int j=0;j<m;j++){
if(a[i][j]>max){
max=a[i][j];
pozi=i;
pozj=j;
}
}
printf(“\nElementi me i madh i rreshtit %d eshte %d.”,i+1,max);
printf(“\nKy element gjendet ne tabele ne pozicionin a[%d][%d].\n”,pozi,pozj);
}
}
int main(){
int a[n][m];
printf(“Fut elementet e tabeles : \n”);
njehsimtabele(a);
printf(“\nUshtrimi nuk e kerkon afishimin e tabeles.\nE ilustrova qe te keni te lehte kontrollin e saktesise se pergjigjes.”);
afishimtabele(a);
funksion(a);
getch();
return 0;
}

_____________________________________

Ushtrimi 6 :

#include<stdio.h>
#include<conio.h>
const int n=5,m=5;
void njehsimtabele(int t[n][m]){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&t[i][j]);
}
}
void afishimtabele(int t[n][m]){
for(int i=0;i<n;i++){
printf(“\n\n”);
for(int j=0;j<m;j++)printf(“\t%d”,t[i][j]);
}
printf(“\n”);
}
void funksion(int a[n][m]){
int perkohesisht;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
perkohesisht=a[0][j];
a[0][j]=a[n-1][j];
a[n-1][j]=perkohesisht;
}
}

int main(){
int a[n][m];
printf(“Fut elementet e tabeles : \n”);
njehsimtabele(a);
funksion(a);
afishimtabele(a);
getch();
return 0;
}

___________________________________________

Ushtrimi 7 :

#include<stdio.h>
#include<conio.h>
const int n=5,m=5;
void njehsimtabele(int t[n][m]){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&t[i][j]);
}
}
void afishimtabele(int t[n][m]){
for(int i=0;i<n;i++){
printf(“\n\n”);
for(int j=0;j<m;j++)printf(“\t%d”,t[i][j]);
}
printf(“\n”);
}
void funksion(int a[n][m]){
int perkohesisht;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
if(i==j){
perkohesisht=a[i][j];
a[i][j]=a[n-1][j];
a[n-1][j]=perkohesisht;
}
}
}
int main(){
int a[n][m];
printf(“Fut elementet e tabeles : \n”);
njehsimtabele(a);
funksion(a);
afishimtabele(a);
getch();
return 0;
}
_____________________________________

Ushtrimi 8 :

#include<stdio.h>
#include<conio.h>
const int n=5,m=5;
void njehsimtabele(int t[n][m]){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&t[i][j]);
}
}
void afishimtabele(int t[n][m]){
for(int i=0;i<n;i++){
printf(“\n\n”);
for(int j=0;j<m-1;j++)printf(“\t%d”,t[i][j]);
}
printf(“\n”);
}
void funksion(int a[n][m]){
for(int i=0;i<n;i++)
for(int j=1;j<m-1;j++)
a[i][j]=a[i][j+1];
}
int main(){
int a[n][m];
printf(“Fut elementet e tabeles : \n”);
njehsimtabele(a);
funksion(a);
afishimtabele(a);
getch();
return 0;
}

_____________________________________

Ushtrimi 9 :

#include<stdio.h>
#include<conio.h>
int main(){
int i,j,n;
printf(“\nJep permasen e tabeles : “);
scanf(“%d”,&n);
int a[n][n],b[n][n];
printf(“Jep elementet e tabeles : \n”);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
printf(“Jep elementin e %d te rreshtit te %d te tabeles : “,j+1,i+1);
scanf(“%d”,&a[i][j]);
b[j][i]=a[i][j];
}
}
printf(“\nTabela e transpozuar eshte: \n”);
for(i=0;i<n;i++){
printf(“\n\n”);
for(j=0;j<n;j++)
printf(“\t%d”,b[i][j]);
printf(“\n”);
}
getch();
return 0;
}

_____________________________________

Ushtrimi 10 :

#include<stdio.h>
#include<conio.h>
int main(){
int n,m;
printf(“Jep numrin e lendeve :”);
scanf(“%d”,&n);
printf(“Jep numrin e studenteve:”);
scanf(“%d”,&m);
char lende[n][25];
for (int i=0;i<n;i++){
printf(“Jep lenden e %d :”,i+1);
scanf(“%s”,&lende[i]);
}
char student[m][20];
for(int j=0;j<m;j++){
printf(“Jep emrin e studentit te %d :”,j+1);
scanf(“%s”,&student[j]);
}
int T[n][m];
for (int i=0;i<n;i++)
for (int j=0;j<m;j++){
printf(“Jep noten qe studenti %s ka marre ne lenden %s :”,student[j],lende[i]);
scanf(“%d”,&T[i][j]);
}
int sasia,max=0,poz,prov=-1;
for(int i=0;i<m;i++){
sasia=0;
for(int j=0;j<n;j++){
if(T[i][j]==10){
prov++;
sasia++;
if(sasia>max){
max=sasia;
poz=i;
}
}
}
}
if(prov==-1)printf(“\n\tAsnje student nuk eshte vleresuar me noten 10.”);
else printf(“\n\tLenda me me shume 10 eshte %s.”,lende[poz]);
float mes;
int shuma,pozk,maxk=-999;
for(int j=0;j<m;j++){
shuma=0;
mes=0;
for(int i=0;i<n;i++){
shuma=shuma+T[i][j];
mes=shuma/n;
if(mes>maxk){
maxk=mes;
pozk=j;
}
}
}
printf(“\n\tStudenti me mesatare me te larte eshte %s.”,student[pozk]);
getch();
return 0;
}

_____________________________________

Studime të mbara!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: