Сравнить коммиты
6 Коммитов
5fe9d80705
...
master
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
18ff2100f6 | ||
| beb0d24a79 | |||
| 21a6cf40ce | |||
| 8778770f4e | |||
| ae07c72c0b | |||
| f255d27719 |
87
lab01.depend
87
lab01.depend
@@ -3,12 +3,13 @@
|
|||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1694257548 source:c:\users\texas\desktop\lab01\main.cpp
|
1696098686 source:c:\users\texas\desktop\lab01\main.cpp
|
||||||
<math.h>
|
<math.h>
|
||||||
<vector>
|
<vector>
|
||||||
<iostream>
|
<iostream>
|
||||||
<string.h>
|
<sstream>
|
||||||
<curl/curl.h>
|
<curl/curl.h>
|
||||||
|
<string>
|
||||||
"histogram.h"
|
"histogram.h"
|
||||||
"text.h"
|
"text.h"
|
||||||
"svg.h"
|
"svg.h"
|
||||||
@@ -84,3 +85,85 @@
|
|||||||
|
|
||||||
1694255976 c:\users\texas\desktop\lab01\curl\include\curl\typecheck-gcc.h
|
1694255976 c:\users\texas\desktop\lab01\curl\include\curl\typecheck-gcc.h
|
||||||
|
|
||||||
|
1696103005 source:c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\histogram.cpp
|
||||||
|
"histogram.h"
|
||||||
|
|
||||||
|
1696103005 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1696103005 source:c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\svg.cpp
|
||||||
|
"svg.h"
|
||||||
|
<math.h>
|
||||||
|
|
||||||
|
1696103005 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\svg.h
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
<string>
|
||||||
|
|
||||||
|
1696105472 source:c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\text.cpp
|
||||||
|
"text.h"
|
||||||
|
<math.h>
|
||||||
|
|
||||||
|
1696104652 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\text.h
|
||||||
|
<vector>
|
||||||
|
<iostream>
|
||||||
|
|
||||||
|
1696106452 source:c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\main.cpp
|
||||||
|
<math.h>
|
||||||
|
<vector>
|
||||||
|
<iostream>
|
||||||
|
<sstream>
|
||||||
|
<curl/curl.h>
|
||||||
|
<string>
|
||||||
|
"histogram.h"
|
||||||
|
"text.h"
|
||||||
|
"svg.h"
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\curl.h
|
||||||
|
"curlver.h"
|
||||||
|
"system.h"
|
||||||
|
<stdio.h>
|
||||||
|
<limits.h>
|
||||||
|
<osreldate.h>
|
||||||
|
<sys/types.h>
|
||||||
|
<time.h>
|
||||||
|
<winsock2.h>
|
||||||
|
<ws2tcpip.h>
|
||||||
|
<sys/select.h>
|
||||||
|
<sys/socket.h>
|
||||||
|
<sys/time.h>
|
||||||
|
"easy.h"
|
||||||
|
"multi.h"
|
||||||
|
"urlapi.h"
|
||||||
|
"options.h"
|
||||||
|
"header.h"
|
||||||
|
"websockets.h"
|
||||||
|
"typecheck-gcc.h"
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\curlver.h
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\system.h
|
||||||
|
<ConditionalMacros.h>
|
||||||
|
<winsock2.h>
|
||||||
|
<windows.h>
|
||||||
|
<ws2tcpip.h>
|
||||||
|
<sys/types.h>
|
||||||
|
<sys/socket.h>
|
||||||
|
<sys/poll.h>
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\easy.h
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\multi.h
|
||||||
|
"curl.h"
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\urlapi.h
|
||||||
|
"curl.h"
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\options.h
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\header.h
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\websockets.h
|
||||||
|
|
||||||
|
1694255976 c:\users\texas\desktop\Íîâàÿ ïàïêà\cs-lab34\curl\include\curl\typecheck-gcc.h
|
||||||
|
|
||||||
|
|||||||
48
lab01.layout
48
lab01.layout
@@ -2,34 +2,14 @@
|
|||||||
<CodeBlocks_layout_file>
|
<CodeBlocks_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveTarget name="Debug" />
|
<ActiveTarget name="Debug" />
|
||||||
<File name="text.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="13" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="69" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="histogram.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="16" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="175" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="main.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="15" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="909" topLine="23" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="svg.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="20" zoom_2="0">
|
<File name="svg.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="20" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="168" topLine="0" />
|
<Cursor1 position="168" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="svg.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="17" zoom_2="0">
|
<File name="text.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="11" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="18" topLine="0" />
|
<Cursor1 position="228" topLine="0" />
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="histogram.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="17" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="566" topLine="0" />
|
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name=".gitignore" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="15" zoom_2="0">
|
<File name=".gitignore" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="15" zoom_2="0">
|
||||||
@@ -37,9 +17,29 @@
|
|||||||
<Cursor1 position="19" topLine="0" />
|
<Cursor1 position="19" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="text.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="11" zoom_2="0">
|
<File name="main.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="15" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="448" topLine="0" />
|
<Cursor1 position="1652" topLine="58" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="text.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="13" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="160" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="histogram.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="17" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="906" topLine="18" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="svg.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="17" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1806" topLine="34" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="histogram.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="16" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="175" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
</CodeBlocks_layout_file>
|
</CodeBlocks_layout_file>
|
||||||
|
|||||||
109
main.cpp
109
main.cpp
@@ -1,8 +1,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <sstream>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
@@ -14,42 +15,110 @@ using namespace std;
|
|||||||
struct Input {
|
struct Input {
|
||||||
vector<double> numbers;
|
vector<double> numbers;
|
||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
float n;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Input
|
Input
|
||||||
input_data(istream& in) {
|
input_data(istream& in,bool prompt) {
|
||||||
|
string a, b, c;
|
||||||
|
if(prompt== true){
|
||||||
|
a = "Enter number count:";
|
||||||
|
b = "Enter numbers:";
|
||||||
|
c = "Enter bin count:";
|
||||||
|
}
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
cerr << "Enter number count: ";
|
cerr << a;
|
||||||
in >> number_count;
|
in >> number_count;
|
||||||
|
|
||||||
Input on;
|
Input on;
|
||||||
on.numbers.resize(number_count);
|
on.numbers.resize(number_count);
|
||||||
for (size_t i = 0; i < number_count; i++) {
|
for (size_t i = 0; i < number_count; i++) {
|
||||||
cerr << "Enter number " << i+1 << ": ";
|
//cerr << b << i+1 << ": ";
|
||||||
in >> on.numbers[i];}
|
in >> on.numbers[i];}
|
||||||
cerr << "Enter bin count: ";
|
cerr << c;
|
||||||
in >> on.bin_count;
|
in >> on.bin_count;
|
||||||
|
|
||||||
on.n = 0;
|
|
||||||
if (on.bin_count==0){
|
|
||||||
on.bin_count = sqrt(number_count);
|
|
||||||
on.n = 1;
|
|
||||||
if (on.bin_count > 25){
|
|
||||||
on.bin_count = 1 + log2(number_count);
|
|
||||||
on.n = 2;}}
|
|
||||||
|
|
||||||
return on;
|
return on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
|
||||||
|
size_t data_size = item_size * item_count;
|
||||||
|
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
||||||
|
buffer->write(reinterpret_cast<const char*>(items), data_size);
|
||||||
|
return data_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
Input
|
||||||
|
download(const string& address) {
|
||||||
|
stringstream buffer;
|
||||||
|
CURL* curl = curl_easy_init();
|
||||||
|
if(curl) {
|
||||||
|
CURLcode res;
|
||||||
|
|
||||||
|
|
||||||
int main()
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||||
{
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
||||||
|
|
||||||
auto in = input_data(cin);
|
res = curl_easy_perform(curl);
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
if(res != CURLE_OK){
|
||||||
|
cerr << curl_easy_strerror(res);
|
||||||
|
exit(1);}
|
||||||
|
curl_easy_cleanup(curl);}
|
||||||
|
return input_data(buffer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]){
|
||||||
|
Input input;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
string adr, format, type;
|
||||||
|
if ((adr=argv[1]).substr(0,7)!= "http://"){
|
||||||
|
if ((format=argv[1])== "-format"){
|
||||||
|
if ((type=argv[2])== "svg"){
|
||||||
|
input = download(argv[3]);
|
||||||
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
show_histogram_svg(bins);
|
show_histogram_svg(bins);
|
||||||
|
}
|
||||||
|
else if ((type=argv[2])== "text"){
|
||||||
|
input = download(argv[3]);
|
||||||
|
|
||||||
|
auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
|
show_histogram_text(bins, input.bin_count);}
|
||||||
|
else
|
||||||
|
cerr << "wrong type";}}
|
||||||
|
else{
|
||||||
|
if ((format=argv[2])== "-format"){
|
||||||
|
if (argc ==3)
|
||||||
|
cerr << "wrong type";
|
||||||
|
else
|
||||||
|
if ((type=argv[3])== "svg"){
|
||||||
|
input = download(argv[1]);
|
||||||
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
|
show_histogram_svg(bins);}
|
||||||
|
|
||||||
|
else if ((type=argv[3])== "text"){
|
||||||
|
input = download(argv[1]);
|
||||||
|
|
||||||
|
auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
|
show_histogram_text(bins, input.bin_count);}
|
||||||
|
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//auto bins = make_histogram(in.numbers, in.bin_count);
|
||||||
|
//show_histogram_text(bins, in.bin_count, in.n);
|
||||||
|
|
||||||
|
|
||||||
|
/*if ((adr=argv[1]).substr(0,7)== "http://"){
|
||||||
|
input = download(argv[1]);
|
||||||
|
if ((type=argv[2])== "svg"){
|
||||||
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
|
show_histogram_svg(bins);}*/
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
9
text.cpp
9
text.cpp
@@ -4,13 +4,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_text(vector<size_t>& bins, size_t bin_count, float n){
|
show_histogram_text(vector<size_t>& bins, size_t bin_count){
|
||||||
if (n != 0){
|
|
||||||
cout << "bin count = " << bin_count;
|
|
||||||
if (n == 1)
|
|
||||||
cout << " using 1st" << '\n';
|
|
||||||
else
|
|
||||||
cout << " using 2nd" << '\n';}
|
|
||||||
for (size_t i = 0; i < bin_count; i++) {
|
for (size_t i = 0; i < bin_count; i++) {
|
||||||
if (bins[i]<100)
|
if (bins[i]<100)
|
||||||
cout << " ";
|
cout << " ";
|
||||||
@@ -20,4 +14,5 @@ show_histogram_text(vector<size_t>& bins, size_t bin_count, float n){
|
|||||||
for (size_t j = 0; j < bins[i]; j++){
|
for (size_t j = 0; j < bins[i]; j++){
|
||||||
cout << "*";}
|
cout << "*";}
|
||||||
cout << '\n';}
|
cout << '\n';}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
2
text.h
2
text.h
@@ -3,6 +3,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void show_histogram_text(std::vector<size_t>& bins, size_t bin_count, float n);
|
void show_histogram_text(std::vector<size_t>& bins, size_t bin_count);
|
||||||
|
|
||||||
#endif // TEXT_H_INCLUDED
|
#endif // TEXT_H_INCLUDED
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user