0% found this document useful (0 votes)
92 views

1

1. The document contains code for three C++ programs. The first program calculates the highest average grade of students from a list. The second program calculates conduct grades for students based on their number of absences. The third program checks if two numbers are mirrored numbers or not.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

1

1. The document contains code for three C++ programs. The first program calculates the highest average grade of students from a list. The second program calculates conduct grades for students based on their number of absences. The third program checks if two numbers are mirrored numbers or not.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.Program care calculeaza cea mai mare medie a elevilor dintr-o lista #include<iostream.h> #include<conio.h> #include<stdio.

h> typedef struct { char nume[20], scoala[30]; int media, venit; } situatie; situatie elev[30]; int n,i,k,s; void main() { clrscr(); cout<<"Nuamrul de elevi"; cin>>n; k=1; s=0; for(i=1;i<=n;i++) {cout<<"Nume "<<i<<" "; cin>>elev[i].nume; cout<<"Scoala "<<i<<" "; cin>>elev[i].scoala; cout<<"Media "<<i<<" "; cin>>elev[i].media; cout<<"Venit "<<i<<" "; cin>>elev[i].venit; cout<<endl; s=s+elev[i].media; } cout<<endl; for(i=1;i<=n;i++) { if(elev[i].media>elev[k].media) k=i; } float media=s/n; cout<<"Media pe clasa "<<media; cout<<"\nElevul cu cea mai mare medie "<<elev[k].nume<<"\n de la scoala "; puts(elev[k].scoala); cout<<" are media "<<elev[k].media<<" si un venit de "<<elev[k].venit; getch(); }

2. //evidenta elevilor dintr-o scoala si calculul notei la purtare in functie de nr de absente


#include <iostream.h> #include<conio.h> #include<stdio.h> typedef struct {char nume[20]; int abs,nota; } catalog; catalog elev[30]; int n, i;

void main() { clrscr(); cout<<"Introdu numarul elevilor "; cin>>n; for(i=1;i<=n;i++) { cout<<"\n\nNume elev "; gets(elev[i].nume); cout<<"Numar absente"; cin>>elev[i].abs; if(elev[i].abs<10) elev[i].nota=10; else if(elev[i].abs>=10&&elev[i].abs<40) elev[i].nota=9; else if(elev[i].abs>=40&&elev[i].abs<70) elev[i].nota=8; else elev[i].nota=4; cout<<"Nota la purtare "<<elev[i].nota; } getch(); } 3.//decide daca doua numere sunt oglidite sau nu #include<iostream.h> #include<conio.h> #include<stdio.h> #include<fstream.h> typedef struct { int x,y; }pereche; pereche nr[20]; int n,i,aux,temp; void main() { cout<<"Introdu nr de perechi "; cin>>n; for(int i=1;i<=n;i++) {cout<<"\nPerechea "<<i<<"\nx="; cin>>nr[i].x; cout<<"y="; cin>>nr[i].y; aux=0; temp=nr[i].y; do { aux=aux*10+temp%10; temp=temp/10; } while(temp!=0); if(aux==nr[i].x) cout<<nr[i].x<<","<<nr[i].y<<endl; else cout<<"Nu sunt numere oglindite\n"; } getch(); }

//analog cu anterioarea, dar foloseste fisiere


#include<iostream.h> #include<conio.h> #include<stdio.h> #include<fstream.h> typedef struct { int x,y; }pereche; pereche nr[20]; int n,i,aux,temp; ifstream f; main() { f.open("perechi.txt"); f>>n; for(int i=1;i<=n;i++) {cout<<"\nPerechea "<<i<<": "; f>>nr[i].x; f>>nr[i].y; aux=0; temp=nr[i].y; do { aux=aux*10+temp%10; temp=temp/10; } while(temp!=0); if(aux==nr[i].x) cout<<nr[i].x<<","<<nr[i].y<<endl; else cout<<"\nNu sunt numere oglindite\n"; } getch(); }

You might also like