commit 240eb6a80e1f43e7bc2dbf9ab2009d262a9edbdf Author: MaryK Date: Mon Apr 3 13:54:42 2023 +0300 Begin diff --git a/bin/Debug/03-scaling.expected.txt b/bin/Debug/03-scaling.expected.txt new file mode 100644 index 0000000..693ba1a --- /dev/null +++ b/bin/Debug/03-scaling.expected.txt @@ -0,0 +1,3 @@ + 9|****** + 33|************************* +100|**************************************************************************** diff --git a/bin/Debug/03-scaling.input.txt b/bin/Debug/03-scaling.input.txt new file mode 100644 index 0000000..2539400 --- /dev/null +++ b/bin/Debug/03-scaling.input.txt @@ -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 diff --git a/bin/Debug/NULL b/bin/Debug/NULL new file mode 100644 index 0000000..f737cdb --- /dev/null +++ b/bin/Debug/NULL @@ -0,0 +1 @@ +enter amount of numberslet's introduse arrayenter amount of intervals \ No newline at end of file diff --git a/bin/Debug/devlab1.exe b/bin/Debug/devlab1.exe new file mode 100644 index 0000000..71c1363 Binary files /dev/null and b/bin/Debug/devlab1.exe differ diff --git a/bin/Debug/expected.txt b/bin/Debug/expected.txt new file mode 100644 index 0000000..480b121 --- /dev/null +++ b/bin/Debug/expected.txt @@ -0,0 +1,3 @@ +3|*** +5|**V^* +2|** \ No newline at end of file diff --git a/bin/Debug/input.txt b/bin/Debug/input.txt new file mode 100644 index 0000000..9bbd76e --- /dev/null +++ b/bin/Debug/input.txt @@ -0,0 +1,3 @@ +10 +3 3 3 4 4 4 4 4 5 5 +3 \ No newline at end of file diff --git a/bin/Debug/lab1.bat b/bin/Debug/lab1.bat new file mode 100644 index 0000000..38be93e --- /dev/null +++ b/bin/Debug/lab1.bat @@ -0,0 +1,2 @@ +devlab1.exe <03-scaling.input.txt >output.txt 2>NUL +fc /N output.txt 03-scaling.expected.txt \ No newline at end of file diff --git a/bin/Debug/output.txt b/bin/Debug/output.txt new file mode 100644 index 0000000..07e2eaf --- /dev/null +++ b/bin/Debug/output.txt @@ -0,0 +1,3 @@ + 9|****** + 33|******^****************** +100|*************************^************************************************** diff --git a/devlab1.cbp b/devlab1.cbp new file mode 100644 index 0000000..f398066 --- /dev/null +++ b/devlab1.cbp @@ -0,0 +1,41 @@ + + + + + + diff --git a/devlab1.depend b/devlab1.depend new file mode 100644 index 0000000..2186c4e --- /dev/null +++ b/devlab1.depend @@ -0,0 +1,5 @@ +# depslib dependency file v1.0 +1676897437 source:c:\program files\codeblocks\devlab1\main.cpp + + + diff --git a/devlab1.layout b/devlab1.layout new file mode 100644 index 0000000..314cf27 --- /dev/null +++ b/devlab1.layout @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/input.txt b/input.txt new file mode 100644 index 0000000..9bbd76e --- /dev/null +++ b/input.txt @@ -0,0 +1,3 @@ +10 +3 3 3 4 4 4 4 4 5 5 +3 \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..4e75e44 --- /dev/null +++ b/main.cpp @@ -0,0 +1,163 @@ +#include +#include +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 xs(n); + cerr<<"let's introduse array"; + for(i=0; i < n; i++) + { + cin>> xs[i]; + } + cerr << "enter amount of intervals"; + cin >> m; + vector 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] bmax) bmax=b[i]; + ibmax = i; + } + //cout< MAX_ASTERISK) + { + for(int j=0; j < m; j++) + { + if (b[j]<100) + { + cout<<" "; + } + if (b[j]<10) + { + cout<<" "; + } + + height = 76 * ( static_cast(b[j]) / bmax); + hem = 76 * ( static_cast(b[j-1]) / bmax); + hep = 76 * ( static_cast(b[j+1]) / bmax); + cout< 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<(b[j]) / bmax); + hem = 76 * ( static_cast(b[j-1]) / bmax); + hep = 76 * ( static_cast(b[j+1]) / bmax); + cout< 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<