,  ,

- C++

> > >

 
C++ HDC http://www.cyberforum.ru/cpp-beginners/thread634697.html
1) HDC ? , WM_CREATE : hdc = BeginPaint(hWnd, &ps); hdc = GetDC(hWnd); WM_CREATE - ...
C++ ;b x:3-0,2x^2+0,3x-1,2=0; c . 1. .... http://www.cyberforum.ru/cpp-beginners/thread634686.html
C++
, " ". . . ...
C++ ,
: , . , , ,...
C++ ++ http://www.cyberforum.ru/cpp-beginners/thread634673.html
. ++ . " C++ 21 " ...
C++ ! , , char, char * string. ? //char text="";//tak ne poidet //char *text="";//tak toje ne...

-==-
 FAQ
10.08.2012, 14:39
D1garch, -
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <ctime>
#include <fstream>
#include <iostream>
using namespace std;
 
/**/ //òå ñòðîêè êîòîðûå îòìå÷å*û ýòèì ç**êîì ïîñëå
//óñïåø*ûõ òåñòîâ ïðîñòî óä*ëÿåì
ofstream log("log.txt");//Îáúÿâëÿåì **ø ïîòîê ç*ïèñè
const int N = 5;//Ïóñòü áóäåò ì*ññèâ èç 5-òè ýëåìå*òîâ
 
//Ôó*êöèÿ ïå÷*ò*åò ì*ññèâ ** ýêð**å
void showArr(int n, int * arr);
//Ôó*êöèÿ ð**äîè\ì*î ç*ïîë*ÿåò ì*ññèâ
void fillArr(int n, int * arr);
//Ñîáñòâå**î ôó*êöèÿ ç*ïèñûâ*åò â ì*ññèâ
//âìåcòî i-ãî ýëåìå*ò* ðåçóëüò*ò val/arr[i]
//ïîì*èì ÷òî ó **ñ ã*ð**òèðîâ**î â ì*ññèâå åñòü 0
void divArr (int n, int * arr, int val);
 
//Ïåðåãðóæå***ÿ ôó*êöèÿ îñóùåñòâëÿþù*ÿ ç*ïèñü â ïîòîê ifs 
//ð*çìåð* è ç**÷å*èé ì*ññèâ* arr
void showArr(int n, int * arr, ofstream &ofs);
 
int main()
{
    int a[N] = {0};
    //Ýòî áóäåò è*äåêñ ýëåìå*ò* ñ *óë¸âûì ç**÷å*èåì
    int j = rand()%(N - 1);
    //Í*ïîë*ÿåì ì*ññèâ *å*óëåâûìè ç**÷å*èÿìè ñëó÷*é*ûì îáð*çîì
    fillArr(N, a);
    //Ïðèñâ*åâ*åì ç**÷å*èå 0 j - ìó è*äåêñó
    a[j] = 0;//Ïðè÷¸ì ÿ *å ç**þ ê*êîé ýòî ïî ñ÷¸òó 
    //è*äåêñ è ïðîãð*ìì* äî **÷*ë* ð*áîòû *å ç**åò
    //êîðî÷å ò*ê ñê*ç*òü ð**äîì**ÿ îøèáê*
 
    //ïå÷*ò*åì ýëåìå*òû ì*ññèâ*
    cout<<"Input  array : ";showArr(N, a);
    divArr (N, a, 11);//Âîò **ø* êîððåêò**ÿ ôó*êöèÿ,
    //êîòîð*ÿ *åêîððåêò*î îòð*áîò*åò ïðè äåëå*èè ** 0
    cout<<"Output array : ";showArr(N, a);
    
    return 0;
}
 
void showArr(int n, int * arr)
{
    for(int i = 0; i < n; i++)
        cout<<arr[i]<<" ";
    cout<<endl;
}
 
void fillArr(int n, int * arr)
{
    //Ñîáñòâå**î îãîâîðå***ÿ ì*îé âñò*âê* â**÷*ëå è êî*öå ôó*êöèè
    /**/log<<"\tfillArr started :\nparams > \n";
    /**/showArr(n, arr,log);/**/
    srand(time(0));
    for(int i = 0; i < n; i++)
        arr[i] = 1 + rand()%10;
    /**/log<<"\tfillArr ended   :\nparams > \n";
    /**/showArr(n, arr,log);/**/
}
 
void divArr (int n, int * arr, int val)
{
    /**/log<<"\tdivArr started :\nparams > \n";
    /**/showArr(n, arr,log);/**/
    srand(time(0));
    for(int i = 0; i < n; i++)
    {
        arr[i] = val / arr[i];
        /**/log<<"\tdivArr iteration :"<<i + 1<<endl;
        /**/log<<"\tdivArr params > \n";
        /**/showArr(n, arr,log);/**/
        
    }
    /**/log<<"\tdivArr ended   :\nparams > \n";
    /**/showArr(n, arr,log);/**/
}
 
 
//ôó*êöèÿ ç*ïèøåò â ïîòîê ì*ññèâ åñëè arr arr != 0 
void showArr(int n, int * arr, ofstream &ofs)
{
    if(arr)
    {
        ofs<<n<<endl;
        for(int i = 0; i < n; i++)
            ofs<<arr[i]<<" ";
        ofs<<endl;
    }
}
log.txt
fillArr started :
params >
5
0 0 0 0 0
fillArr ended :
params >
5
10 6 1 6 6
divArr started :
params >
5
10 0 1 6 6
divArr iteration :1
divArr params >
5
1 0 1 6 6
- 2-
1
   
 
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.