Сommit
240eb6a80e
@ -0,0 +1,3 @@
|
|||||||
|
9|******
|
||||||
|
33|*************************
|
||||||
|
100|****************************************************************************
|
@ -0,0 +1,5 @@
|
|||||||
|
142
|
||||||
|
1 1 1 1 1 1 1 1 1
|
||||||
|
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
|
||||||
|
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
|
||||||
|
3
|
@ -0,0 +1 @@
|
|||||||
|
enter amount of numberslet's introduse arrayenter amount of intervals
|
Двоичный файл не отображается.
@ -0,0 +1,3 @@
|
|||||||
|
3|***
|
||||||
|
5|**V^*
|
||||||
|
2|**
|
@ -0,0 +1,3 @@
|
|||||||
|
10
|
||||||
|
3 3 3 4 4 4 4 4 5 5
|
||||||
|
3
|
@ -0,0 +1,2 @@
|
|||||||
|
devlab1.exe <03-scaling.input.txt >output.txt 2>NUL
|
||||||
|
fc /N output.txt 03-scaling.expected.txt
|
@ -0,0 +1,3 @@
|
|||||||
|
9|******
|
||||||
|
33|******^******************
|
||||||
|
100|*************************^**************************************************
|
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="devlab1" />
|
||||||
|
<Option pch_mode="2" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug">
|
||||||
|
<Option output="bin/Debug/devlab1" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Debug/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-g" />
|
||||||
|
</Compiler>
|
||||||
|
</Target>
|
||||||
|
<Target title="Release">
|
||||||
|
<Option output="bin/Release/devlab1" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Release/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-O2" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-s" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
</Build>
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-Wall" />
|
||||||
|
<Add option="-fexceptions" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-static-libstdc++" />
|
||||||
|
</Linker>
|
||||||
|
<Unit filename="main.cpp" />
|
||||||
|
<Extensions />
|
||||||
|
</Project>
|
||||||
|
</CodeBlocks_project_file>
|
@ -0,0 +1,5 @@
|
|||||||
|
# depslib dependency file v1.0
|
||||||
|
1676897437 source:c:\program files\codeblocks\devlab1\main.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_layout_file>
|
||||||
|
<FileVersion major="1" minor="0" />
|
||||||
|
<ActiveTarget name="Debug" />
|
||||||
|
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="3670" topLine="115" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
</CodeBlocks_layout_file>
|
@ -0,0 +1,3 @@
|
|||||||
|
10
|
||||||
|
3 3 3 4 4 4 4 4 5 5
|
||||||
|
3
|
@ -0,0 +1,163 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const size_t SCREEN_WIDTH = 80;
|
||||||
|
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
|
||||||
|
unsigned int n;
|
||||||
|
size_t m;
|
||||||
|
int i;
|
||||||
|
char sim;
|
||||||
|
float lo,hi,dif, maxxs,minxs;
|
||||||
|
cerr<< "enter amount of numbers";
|
||||||
|
cin>>n;
|
||||||
|
vector <float> xs(n);
|
||||||
|
cerr<<"let's introduse array";
|
||||||
|
for(i=0; i < n; i++)
|
||||||
|
{
|
||||||
|
cin>> xs[i];
|
||||||
|
}
|
||||||
|
cerr << "enter amount of intervals";
|
||||||
|
cin >> m;
|
||||||
|
vector <size_t> b(m);
|
||||||
|
maxxs = minxs = xs[0];
|
||||||
|
for (i=0; i < n; i++)
|
||||||
|
{
|
||||||
|
if (xs[i] > maxxs) maxxs=xs[i];
|
||||||
|
if (xs[i] < minxs) minxs=xs[i];
|
||||||
|
}
|
||||||
|
dif=(maxxs - minxs)/m;
|
||||||
|
for(int i=0; i < n; i++)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for (int j=0; (j < m-1)&&!found; j++)
|
||||||
|
{
|
||||||
|
lo= minxs + j*dif;
|
||||||
|
hi= minxs + (j+1)*dif;
|
||||||
|
if ((lo <= xs[i]) && (xs[i] <hi ))
|
||||||
|
{
|
||||||
|
b[j]++;
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
b[m - 1]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size_t bmax,height,hem,hep;
|
||||||
|
int ibmax;
|
||||||
|
bmax=b[0];
|
||||||
|
for (i=0; i < m; i++)
|
||||||
|
{
|
||||||
|
if (b[i] > bmax) bmax=b[i];
|
||||||
|
ibmax = i;
|
||||||
|
}
|
||||||
|
//cout<<bmax<<endl;
|
||||||
|
if (bmax > MAX_ASTERISK)
|
||||||
|
{
|
||||||
|
for(int j=0; j < m; j++)
|
||||||
|
{
|
||||||
|
if (b[j]<100)
|
||||||
|
{
|
||||||
|
cout<<" ";
|
||||||
|
}
|
||||||
|
if (b[j]<10)
|
||||||
|
{
|
||||||
|
cout<<" ";
|
||||||
|
}
|
||||||
|
|
||||||
|
height = 76 * ( static_cast<double>(b[j]) / bmax);
|
||||||
|
hem = 76 * ( static_cast<double>(b[j-1]) / bmax);
|
||||||
|
hep = 76 * ( static_cast<double>(b[j+1]) / bmax);
|
||||||
|
cout<<b[j]<<'|';
|
||||||
|
|
||||||
|
if (j==0)
|
||||||
|
{
|
||||||
|
for (int u=0; u < height; u++)
|
||||||
|
{
|
||||||
|
if ((b[0] > b[1])&&(u == hep - 1)) cout<<'v';
|
||||||
|
else cout<<'*';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (j == m)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int u = 0; u < height; u++)
|
||||||
|
{
|
||||||
|
if ((b[m] > b[m-1])&&(u == hem-1)) cout<<'^';
|
||||||
|
else cout<<'*';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int u=0; u < height; u++)
|
||||||
|
{
|
||||||
|
sim='*';
|
||||||
|
if ((b[j] > b[j-1]) && (u == hem)) sim='^';
|
||||||
|
if ((b[j] > b[j+1])&&(u == hep)&&(u != height)&&(u != 0)) sim='V';
|
||||||
|
if ((b[j-1] == b[j+1])&&(u == hep)) sim='N';
|
||||||
|
cout<<sim;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int j=0; j < m; j++)
|
||||||
|
{
|
||||||
|
if (b[j]<100)
|
||||||
|
{
|
||||||
|
cout<<" ";
|
||||||
|
}
|
||||||
|
if (b[j]<10)
|
||||||
|
{
|
||||||
|
cout<<" ";
|
||||||
|
}
|
||||||
|
|
||||||
|
height = 76 * ( static_cast<double>(b[j]) / bmax);
|
||||||
|
hem = 76 * ( static_cast<double>(b[j-1]) / bmax);
|
||||||
|
hep = 76 * ( static_cast<double>(b[j+1]) / bmax);
|
||||||
|
cout<<b[j]<<'|';
|
||||||
|
|
||||||
|
if (j==0)
|
||||||
|
{
|
||||||
|
for (int u=0; u < b[i]; u++)
|
||||||
|
{
|
||||||
|
if ((b[0] > b[1])&&(u == b[i+1] - 1)) cout<<'v';
|
||||||
|
else cout<<'*';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (j == m)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int u = 0; u < b[i]; u++)
|
||||||
|
{
|
||||||
|
if ((b[m] > b[m-1])&&(u == b[i-1]-1)) cout<<'^';
|
||||||
|
else cout<<'*';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int u=0; u < b[i]; u++)
|
||||||
|
{
|
||||||
|
sim='*';
|
||||||
|
if ((b[j] > b[j-1]) && (u == b[i-1])) sim='^';
|
||||||
|
if ((b[j] > b[j+1])&&(u == b[i+1])&&(u != b[i])&&(u != 0)) sim='V';
|
||||||
|
if ((b[j-1] == b[j+1])&&(u == b[i+1])) sim='N';
|
||||||
|
cout<<sim;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче