Tema 7.docx

  • Uploaded by: SerenaBlaga
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Tema 7.docx as PDF for free.

More details

  • Words: 786
  • Pages: 4
TEMA 7

1. #include using namespace std; void sub ( int &a, int &b) { int c=a%10; a=a/10; b=b*10+c; } int main() { int a,b; cin>>a>>b; sub(a,b); cout< using namespace std; int nr ( float a,float b) { int c,d; float aux; if(a>b) { aux=a; a=b; b=aux; } c=a;d=b; if(c==a) return d-c+1; else return d-c; } int main() { float a,b; cin>>a>>b; cout<
3. #include using namespace std; int produs(int a) { int ok,d=2,p=1; while (a>1) { ok=0; while(a%d==0) {a=a/d; ok++;} if(ok!=0) p=p*d; if(d==2) d++; else d=d+2; } return p; } int main() { float a; cin>>a; cout<<produs(a); return 0; } 4. #include using namespace std; void sumazec(int a,int n,int &s) { s=0; int p=1,c; float b; b=1.0/a; while(n) {p=p*10; n--;} c=b*p; while(c) {s=s+c%10; c=c/10;} } int main() { int a,s,n; cin>>a>>n; sumazec(a,n,s); cout<<s; return 0; }

5. #include using namespace std; int matdiag(int n, int a[100][100]) { int s,x,i,j; for(i=1;i<=n;i++) { s=0; for(j=1;j<=n;j++) if(i!=j) s=s+a[i][j]; else x=a[i][j]; if(x<s) return 0; } return 1; } int main() { int a[100][100],n,i,j; cin>>n; for(i=1;i<=n;i++) for(j=1;j<=n;j++) cin>>a[i][j]; cout<<matdiag(n,a); return 0; } 6. #include using namespace std; int panta(int n) { int max=0,min=9; while(n) { if(n%10>max) max=n%10; if(n%10<min) min=n&10; n=n/10; } return max-min; } int main() { int n; cin>>n; cout<<panta(n); return 0; }

TEMA 7

7. #include using namespace std; void divizor(int n,int &d,int &p) { d=2; while(n>1) { p=0; while(n%d==0) {n=n/d; p++;} if(p!=0) break; if(d==2) d++; else d=d+2; } } int main() { int n,d,p; cin>>n; divizor(n,d,p); cout<
9. #include using namespace std; int prim (int x) { if(x<2) return 0; if(x%2==0&&x!=2) return 0; for(int d=3;d*d<=x;d=d+2) if(x%d==0) return 0; return 1; } int prim_max(int n) { n=n-1; while(prim(n)==0) n--; return n; } int main() { int n; cin>>n; cout<<prim_max(n); return 0; }

11. #include using namespace std; int fibonacci(int a,int b) { int x=1,y=1,z; if(a==1&&b==1) return 1; while(y>a>>b; if(fibonacci(a,b)) cout<<"da"; else cout<<"nu"; return 0; }

8. #include using namespace std; int max_diviz (int a,int b) { int aux,d; if(a>b) { aux=a; a=b; b=aux; } for(d=a;d>=10;d--) if(a%d==0&&b%d==0&&d<100) return d; return 1; } int main() { int a,b; cin>>a>>b; cout<<max_diviz(a,b); return 0; }

10. #include using namespace std; void multiplu(int a,int b,int m) { int r,c=a*b,i; while(b) { r=a%b; a=b; b=r; } c=c/a; for(i=1;i<=m;i++) cout<>a>>b>>m; multiplu(a,b,m); return 0; }

12. #include using namespace std; void creare(int n,int m, int a[100][100],int v[100]) { int i,j,k=1; for(j=1;j<=m;j++) for(i=n;i>=1;i--) v[k++]=a[i][j]; } int main() { int a[100][100],n,m,v[100],i,j; cin>>n>>m; for(i=1;i<=n;i++) for(j=1;j<=m;j++) cin>>a[i][j]; creare(n,m,a,v); for(i=1;i<=n*m;i++) cout<
TEMA 7

13. #include using namespace std; void control(int a,int b) { int i,c; c=a%9; for(i=a;i<=b;i++) if(i%9==c) cout<<<" "; } int main() { int a,b; cin>>a>>b; control(a,b); return 0; } 14. #include using namespace std; int perfect(int x) { int s=1,d; for(d=2;d*d<x;d++) if(x%d==0) s=s+d+x/d; if(d*d==x) s=s+d; if(s==x) return 1; return 0; } int nrperfect(int n) { while(perfect(n)==0) n--; return n; } int main() { int n; cin>>n; cout<
15. #include using namespace std; int elimin(int n,int k) { int p=1,nr=0,aux=n; while(n) { nr++; n=n/10; } nr=nr-k; if(nr>0) {while(nr) {p=p*10; nr--;} return aux%p;} else return 0; } int main() { int n,k; cin>>n>>k; if(elimin(n,k)==0) cout<<"NUMAR VID"; else cout<<elimin(n,k); return 0; } 16. #include using namespace std; int prim (int x) { if(x<2) return 0; if(x%2==0&&x!=2) return 0; for(int d=3;d*d<=x;d=d+2) if(x%d==0) return 0; return 1; } int prim_min(int n) { while(prim(n)==0) n++; return n; } int main() { int n; cin>>n; cout<<prim_min(n); return 0; }

17. #include using namespace std; int factori_primi(int x) { int d=2,nr=0,p; while(x>1) { p=0; while(x%d==0) {p++; x=x/d;} if(p!=0) nr++; if(d==2) d++; else d=d+2; } return nr; } int main() { int n,i,x,y,max=0; cin>>n; for(i=1;i<=n;i++) { cin>>x; y=factori_primi(x); if(y>max) max=y; } cout<<max; return 0; }

TEMA 7

18. #include using namespace std; int echilibrat(int n) { int p=0,i=0; while(n) { if((n%10)%2==0) p++; else i++; n=n/10; } if(p==i) return 1; return 0; } int main() { int n; cin>>n; if(echilibrat(n)) cout<<"da"; else cout<<"nu"; return 0; } 19. #include using namespace std; int suma (int x) { int s=0; while(x) { s=s+x%10; x=x/10; } return s; } int deosebit (int n) { int i; for(i=n-1;i>=n/2;i--) if(i+suma(i)==n) return 1; return 0; } int main() { int n; cin>>n; cout<<deosebit(n); return 0; }

20. #include using namespace std; void elim (int n, int &x) { int p=1; x=0; while(n) { if((n%10)%2!=0) {x=n%10*p+x; p=p*10;} n=n/10; } } int main() { int n,x; cin>>n; elim(n,x); cout<<x; return 0; }

Related Documents

Tarea Tema Tema Tema
October 2019 70
Tema
December 2019 3
Tema
June 2020 3
Tema
November 2019 7
Tema
June 2020 4
Tema
August 2019 23

More Documents from "Rodrigo Maylle Espinoza"

Cautarebinara_aplicatii.pdf
November 2019 3
Algelementari.docx
June 2020 2
Info-1.docx
June 2020 5
Eficienta.docx
June 2020 5
Tema 7.docx
November 2019 3