- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main ()
- •Int main ()
- •Int main ()
- •Int main() {
- •Int main()
- •Int main()
- •Int main()
- •Int main() {
- •Int main() {
- •Int main(){
- •Int main() {
- •Int main() {
- •Int main()
- •Int main()
Int main()
{
int N,Sum,A,a,i;
cout <<"N=";
cin >>N;
i=0;
Sum=0;
while (i<N)
{
cin >>a; A=a;
cout <<" " <<A<<endl;
Sum+=A;
i++;
}
cout <<endl;
cout <<"Sum = " <<Sum<< endl;
system("pause");
return 0;
}
9)Описать процедуру RectPS(x1, y1, x2, y2, P, S), вычисляющую периметр P и площадь S прямоугольника со сторонами, параллельными осям координат, по координатам (x1, y1), (x2, y2) его противоположных вершин (x1, y1, x2, y2 — входные, P и S — выходные параметры вещественного типа). С помощью этой процедуры найти периметры и площади трех прямоугольников с данными противоположными вершинами.
#include <iostream>
#include <conio.h>
using namespace std;
#include <cmath>
void RectPS(double x1, double y1, double x2, double y2, double& P, double& S);
Int main()
{
double x1,y1,x2,y2,P,S;
cout << "X1= " ;
cin >>x1;
cout << "Y1= " ;
cin >>y1;
cout << "X2= " ;
cin >>x2;
cout << "Y2= " ;
cin >>y2;
RectPS(x1,y1,x2,y2,P,S);
cout <<"1) P="<<P<<" S="<<S<<endl;
cout << "X1= " ;
cin >>x1;
cout << "Y= " ;
cin >>y1;
cout << "X2= " ;
cin >>x2;
cout << "Y2= " ;
cin >>y2;
RectPS(x1,y1,x2,y2,P,S);
cout <<"1) P="<<P<<" S="<<S<<endl;
cout << "X1= " ;
cin >>x1;
cout << "Y= " ;
cin >>y1;
cout << "X2= " ;
cin >>x2;
cout << "Y2= " ;
cin >>y2;
RectPS(x1,y1,x2,y2,P,S);
cout <<"1) P="<<P<<" S="<<S<<endl;
system("pause");
return 0;
}
void RectPS(double x1, double y1, double x2, double y2, double& P, double& S)
{
P=(abs(x1-x2)+abs(y1-y2))*2;
S=abs(x1-x2)*abs(y1-y2);
}
10)
#include <iostream>
#include <conio.h>
using namespace std;
Int main()
{
int N,i,max;
double P,m,v;
cout << "N=" ;
cin >>N;
cout << "1) m = ";
cin >>m;
cout << "1) v = ";
cin >>v;
P=m/v;
i=1;
max=1;
while (i<N)
{
i++; cout <<i<<") m = ";
cin >>m;
cout <<i<<") v = ";
cin >>v;
if (m/v>P){
max=i; P=m/v;}
}
cout <<"Otvet" <<endl;
cout <<"max="<<max<<endl;
system("pause");
return 0;
}
11)
#include <iostream>
#include <conio.h>
using namespace std;
Int main()
{
int i,N,a[10];
cout << "N=" ;
cin >>N; a[1]=1;
a[2]=1;
for (i=3;i<=N;i++)
{
a[i]=a[i-2]+a[i-1];}
cout <<"Otvet"<< endl;
for (i=1;i<=N;i++)
{
cout <<"a["<<i<<"]="<<a[i]<<endl;}
system("pause");
return 0;
}
12)
#include <iostream>
#include <conio.h>
using namespace std;
Int main()
{
int i,N,b[10],a[10];
cout << "N=" ;
cin >> N;
for (i=1;i<=N;i++)
{
cout <<"a["<<i<<"]=";
cin >>a[i];
cout<<endl;
} b[1]=a[1];
for (i=2;i<=N;i++)
{
b[i]=b[i-1]+a[i];
} cout <<"otvet"<<endl;
cout <<"b[] ";
for (i=1;i<=N;i++)
{
cout <<b[i]<<" ";
}
cout <<endl;
system("pause");
return 0;
}
13)
|
#include<iostream> #include<cmath> using namespace std;
int main(int argc, char **argv) { float x, y, sum; int i, n; cout <<"n = " ; cin >> n; x = 1; y = 1; sum = x / (1 + abs(y)); for ( i = 2; i <= n; i++ ) { y = x + y; x = 0.3 * x; sum = sum + x / (1 + abs(y)); } cout << "SUMA = " << sum <<endl; return 0; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14)
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
