Upload files to "cpp"
This commit is contained in:
parent
90a0a0c624
commit
89246ee0b1
37
cpp/sr.cpp
Normal file
37
cpp/sr.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int a[] = {41, 558, 541, 559,63, 62, 551, 155};
|
||||||
|
int n,i,max,min;
|
||||||
|
float sr,suma;
|
||||||
|
|
||||||
|
n=sizeof(a)/sizeof(int);
|
||||||
|
cout<<"n = "<<n<<endl;
|
||||||
|
for(i=0;i<n;i++)
|
||||||
|
cout<<a[i]<<" ";
|
||||||
|
|
||||||
|
max=a[0];
|
||||||
|
for(i=1;i<n;i++)
|
||||||
|
if(a[i]>max) max=a[i];
|
||||||
|
cout<<"\n max = "<<max;
|
||||||
|
|
||||||
|
min=a[0];
|
||||||
|
for(i=1;i<n;i++)
|
||||||
|
if(a[i]<min) min=a[i];
|
||||||
|
cout<<"\n min= "<<min;
|
||||||
|
|
||||||
|
suma=0;
|
||||||
|
for(i=0;i<n;i++)
|
||||||
|
suma=suma+a[i];
|
||||||
|
cout<<"\n suma = "<<suma;
|
||||||
|
sr=(suma-max-min)/(n-2);
|
||||||
|
cout<<"\n srednia = "<<setprecision(3)<<sr;
|
||||||
|
|
||||||
|
|
||||||
|
system("pause > null");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
19
cpp/sum_2.cpp
Normal file
19
cpp/sum_2.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
//suma liczb parzystych
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int t[] = {4,7,9,3,10,2,5,6};
|
||||||
|
int suma,i,n;
|
||||||
|
n=sizeof(t)/sizeof(t[0]);
|
||||||
|
|
||||||
|
suma=0;
|
||||||
|
for(i=0;i<n;i++)
|
||||||
|
if(t[i]%2==0) suma += t[i];
|
||||||
|
|
||||||
|
cout<<"\n suma = "<<suma;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
19
cpp/tab3.cpp
Normal file
19
cpp/tab3.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int n,i;
|
||||||
|
cout<<"n = ";
|
||||||
|
cin>>n;
|
||||||
|
|
||||||
|
int *a = new int [n];
|
||||||
|
|
||||||
|
for(i=0;i<n;i++){
|
||||||
|
cout<<"a["<<i<<"]=";
|
||||||
|
cin>>a[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete [] a;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
24
cpp/zl.cpp
Normal file
24
cpp/zl.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int i,n;
|
||||||
|
float zl,suma;
|
||||||
|
float f0,f1;
|
||||||
|
cout<<"n = ";
|
||||||
|
cin>>n;
|
||||||
|
f0=0;
|
||||||
|
f1=1;
|
||||||
|
cout<<f0<<" "<<f1<<" ";
|
||||||
|
for(i=2;i<=n;i++){
|
||||||
|
suma=f0+f1;
|
||||||
|
cout<<suma<<" ";
|
||||||
|
f0=f1;
|
||||||
|
f1=suma;
|
||||||
|
}
|
||||||
|
cout<<"\n zl = "<<f1/f0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user