Created
September 19, 2018 20:56
-
-
Save AlexeyRudkovskiy/6d3a6c2299ea589ea6a62a88575b7921 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lab1.cpp: ���������� ����� ����� ��� ����������� ����������. | |
// | |
#include "stdafx.h" | |
#include <stdio.h> | |
#include <iostream> | |
#include<cmath> | |
using namespace std; | |
void l1_1(); | |
void l1_2(); | |
void l1_3(); | |
void l1_4(); | |
void l1_5(); | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
// l1_1(); | |
// l1_2(); | |
//l1_3(); | |
l1_4(); | |
system("pause"); | |
return 0; | |
} | |
void l1_1() { | |
int a = 0; | |
int b = 0; | |
fscanf(stdin,"%d %d",&a, &b); | |
a = a + b; | |
b = a - b; | |
a = a - b; | |
fprintf(stdout, "%d %d", a, b); | |
} | |
void l1_2() { | |
int i1,i2,i3,i4,i5,i6,count=0; | |
for(i1=0;i1<10;i1++) | |
for(i2=0;i2<10;i2++) | |
for(i3=0;i3<10;i3++) | |
for(i4=0;i4<10;i4++) | |
for(i5=0;i5<10;i5++) | |
for(i6=0;i6<10;i6++) | |
if(i1+i2+i3==i4+i5+i6) count++; | |
fprintf(stdout, "%d", count); | |
} | |
void l1_3() { | |
int n = 8; | |
int k = 3; | |
int compsWithInfo = 1; | |
int compsCanCopy = 1; | |
int hours = 0; | |
while (compsWithInfo < n) { | |
compsWithInfo += compsCanCopy; | |
compsCanCopy = compsWithInfo; | |
if (compsCanCopy > k) { | |
compsCanCopy = k; | |
} | |
hours++; | |
printf("%d %d \n", compsCanCopy, compsWithInfo); | |
} | |
printf("Need %d hours", hours); | |
} | |
void l1_4() { | |
int num = 14; | |
int A = 0; | |
int P = 0; | |
for (int i = 0; i < num; i++) { | |
//printf("i = %d\n", i); | |
for (int j = i; j < num; j++) { | |
int sum = 0; | |
//printf("Sum = %d, j = %d\n", sum, j); | |
for (int k = 0; k < j; k++) { | |
//printf("k = %d sum = %d \n", k, sum); | |
sum += i + k; | |
} | |
//printf("sum %d\n", sum); | |
if (sum == num && j > P) { | |
A = i; | |
P = j; | |
} | |
} | |
} | |
printf("A = %d P = %d \n", A, P); | |
} | |
#include<iostream> | |
#include<cmath> | |
using namespace std; | |
const double pi=3.1415926; | |
double x[4],y[4]; | |
double dist(double x,double y) | |
{ | |
return sqrt(x*x+y*y); | |
} | |
void l1_5() | |
{ | |
int n,i; double r,s; | |
//cin>>n>>r; | |
n = 4; | |
r = 1; | |
x[0] = 0; x[1] = 2; x[2] = 2; x[3] = 0; | |
y[0] = 0; y[1] = 0; y[2] = 2; y[3] = 2; | |
//for (i=1; i<=n; i++) cin>>x[i]>>y[i]; | |
s=0; x[n+1]=x[1]; y[n+1]=y[1]; | |
for (i=1; i<=n; i++) { | |
s+=dist(x[i]-x[i+1],y[i]-y[i+1]); | |
} | |
printf("%.2lf\n",s+2*pi*r); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment