17 uždavinys (C++)

Trikampis #include <iostream> #include <cmath> using namespace std; int main() { double x1,x2,x3,y1,y2,y3,ab,cb,ac,AB,AC,CB; cout<<“Iveskite trik virsuniu koordinates x,y”<<endl; cin>>x1>>y1>>x2>>y2>>x3>>y3; ab=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); ac=(x3-x1)*(x3-x1)+(y3-y1)*(y3-y1); cb=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3); AB=sqrt(ab); AC=sqrt(ac); CB=sqrt(cb); if ((round(AB*AB)==round(AC*AC+CB*CB))||(round(AC*AC)==round(AB*AB+CB*CB))||(round(CB*CB)==round(AC*AC+AB*AB))) cout<<“Trikampis status”<<endl; else cout<<“Trikampis nera status”<<endl; system(“Pause”); return 0; }

16 uždavinys (C++)

Pirminiai #include <iostream> #include <cmath> using namespace std; int main() { const int Cn=100; int A[Cn], n, g,i,m,s; g=1; m=0; cout<<“Iveskite masyvo elementu skaiciu”<<endl; cin>>n; while (m<n) { g=g+1; i=1; s=0; while (i<g) { i=i+1; if (g%i==0) s=s+1; } if (s==1) {m=m+1; A[m]=g; cout<<A[m]<<” “;} else m=m; } system(“Pause”); return 0; }

15 uždavinys (C++)

#include <iostream> #include <cmath> using namespace std; int main() { const int Cn=100; int A[Cn],n,i,a,b,k; k=0; cout<<“Iveskite nuo kiek iki kiek kinta”<<endl; cin>>a>>b; for (i=a; i<b; i++) { if (i%2!=0) {k=k+1; A[k]=i; cout<<A[k]<<” “;} } cout<<endl; system(“Pause”); return 0; }

14 uždavinys (C++)

#include <iostream> #include <cmath> using namespace std; int main() { const int Cn=100; int A[Cn], n, suma; suma=0; cout<<“Iveskite masyvo elementu skaiciu”<<endl; cin>>n; cout<<“Iveskite masyvo elementus”<<endl; for (int i=0; i<n; i++) cin>>A[i]; cout<<“Masyve yra sie skaiciai: “<<endl; for (int i=0; i<n; i++) cout<<A[i]<<” “; cout<<endl; for (int i=0; i<n; i++) suma=suma+A[i]; cout<<“Masyvo elementu suma: “<<suma<<endl; […]

13 uždavinys (C++)

#include <iostream> #include <cmath> using namespace std; int main() { const int Cn=100; int i,j,A[Cn],n,c; cout<<“Iveskite kiek masyve elementu”<<endl; cin>>n; cout<<“Iveskite masyvo elementus”<<endl; for (i=0; i<n; i++) cin>>A[i]; cout<<“Masyve yra sie elementai: “<<endl; for (i=0; i<n; i++) cout<<A[i]<<” “; cout<<endl; for (i=0; i<n; i++) for (j=0; j<n; j++) { if (A[i]<A[j]&&i!=j) { c=A[i]; A[i]=A[j]; A[j]=c; […]

12 uždavinys (C++)

#include <iostream> #include <fstream> #include <string> using namespace std; struct studentas { string pav; string vard; int amzius; double vidurk; studentas *sek; }; studentas *pr, *d, *gal, *b, *temp; int main() { string p,v; int dn,met,men,paz,k,amz; double vid; ifstream duom; duom.open(“duom.txt”); pr=NULL; gal=pr; while (!duom.eof()) { vid=0; paz=1; k=0; duom>>p; duom>>v; duom>>met; duom>>men; duom>>dn; if […]

11 uždavinys (C++)

#include <iostream> #include <vector> using namespace std; vector<int> zmones; vector<int> zm; vector<int> komb; static int suma = 0; void spausdina(const vector<int>& v,int n, int k); void go(int offset, int k,int n, int ska); int main() { int n , k, skaicius, kart, l ; cout<<“Iveskite kiek bus zmoniu”<<endl; cin>>n; cout<<“Kiek bus grupiu”<<endl; cin>>k; skaicius=k; for […]

10 uždavinys (C++)

#include <iostream> #include <fstream> #include <string> #include <iomanip> #include <ctime> #include <cstdlib> #include <cstring> using namespace std; struct studentas { string pav; string vard; int amzius; double vidurk; studentas *sek; } *pr; void iveda(); int metai (int m, int mm, int di); double vidurkiss(char* eilute); void vidurkis(struct studentas *d); void amzius(struct studentas *d); void rezultatai […]

9 uždavinys (C++)

#include <iostream> using namespace std; int main() { int **a; int *b; const int Cn=500; int n; a=new int *[Cn]; b=new int; if (a==NULL||b==NULL) cout<<“FUK”<<endl; else { cout<<“n”<<endl; cin>>n; for (int i=0; i<n; i++) { cout<<“b[i]”<<endl; cin>>b[i]; for(int j=0; j<b[i]; j++) cin>>a[i][j]; } for (int i=0; i<n; i++) for(int j=0; j<b[i]; j++) cout<<a[i][j]; } system(“Pause”); […]

8 uždavinys (C++)

#include <iostream> #include <vector> using namespace std; int main() { double arr[ ]= {1.1, 2.2, 3.3, 4.4 }; vector<double> v1 (arr, arr+4) ; // sudaromas vektorius while (!v1.empty ()) // kol netuščias { cout<<v1.back()<<endl; // išvedamas paskutinis elementas v1.pop_back(); // pašalinamas paskutinis elementas } for (int i = 0; i<5; i++) v1.push_back(i); // pridedamas elementas […]