• API
• FAQ
• Tools
• Trends
• Archive
SHARE
TWEET

# Untitled

a guest Jan 12th, 2017 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <string>
3. #include "math.h"
4. #include <cstdlib>
5. #include <cstdio>
6.
7.
8.
9. using namespace std;
10.
11. class Number {
12. private:
13.     char sign;
14.
15.     char* arr;
16.
17.     int schetnamber (int i)
18.     {
19.         return i > 0 ? (int) log10 ((double) i) + 1 : 1;
20.     }
21.     int podschet_par(int kolchisel) {
22.         if (kolchisel % 2 == 0) {
23.             return kolchisel / 2;
24.         }
25.         else {
26.             return kolchisel / 2 + 1;
27.         }
28.     }
29.     void Chifry_arr(int kolvo_par,int number, char *arr) {
30.         int i = 0;
31.         while (number!=0) {
32.             int x = number % 100;
33.
34.             arr[i]=(char)x;
35.             number = number/100;
36.
37.             cout << "vassiv - ";
38.             printf("%d", arr[i]);
39.             cout << "\n";
40.             i++;
41.         }
42.     };
43.
44.
45. public:
46.     Number(char sign, int number) {
47.         int kolchisel = schetnamber(number);
48.         cout << "kolichstvo chisel - " << kolchisel << "\n";
49.         int kolvo_par = podschet_par(kolchisel);
50.         cout << "kolvo_par - " << kolvo_par << "\n";
51.
52.         //double *price = new double[rows];
53.         //arr = new char[kolvo_par];
54.         arr = (char* )malloc(kolchisel * sizeof(char));
55.
56.         Chifry_arr(kolvo_par, number, arr);
57.
58.
59.         this->sign = sign;
60.         //this->arr[0] = number;
61.     }
62.
63.     void printConsole() {
64.         cout << "size of char - " << sizeof(char) << "\n";
65.         cout << "size of array in bytes - " << sizeof(arr) << "\n";
66.         cout << "size of one element of array - " << sizeof(arr[0]) << "\n";
67.         cout << "size of array - " << sizeof(arr)/sizeof(arr[0]) << "\n";
68.         cout << "!!!!!!!!";
69.         char a[6] = {1,2,3,4,5,6};
70.         cout << "size of array in bytes - " << sizeof(a) << "\n";
71.         cout << "size of one element of array - " << sizeof(a[0]) << "\n";
72.         cout << "size of array - " << sizeof(a)/sizeof(a[0]) << "\n";
73.
74.         cout << "!!!!!!!!" << "\n";
75.
76.         cout << sign;
77.
78.         for (int j = 3; j >=0; j--) {
79.             printf("%d", arr[j]);
80.         }
81.     }
82.
83. };
84.
85.
86. int main(){
87. //    int i;
88. //    cout << "vvedite chislo" << endl;
89. //    cin >> i;
90. //    Number number1('+', i);
91.     Number number1('+', 123456);
92.     number1.printConsole();
93.
94.     return 0;
95. }
RAW Paste Data
Top