-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample2.cpp
More file actions
72 lines (56 loc) · 904 Bytes
/
sample2.cpp
File metadata and controls
72 lines (56 loc) · 904 Bytes
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
struct pixel{
int R;
int G;
int B;
};
class image{
private:
int *s;
int picsize;
public:
image(int count=1024)
{
s=new pixel[count];
picsize=count;
}
void Set(pixel p,int i);
pixel Get(int i);
};
void image::Set(pixel p,int i)
{
if (!isFull() && i<picsize)
s[i]=p;
}
pixel image::Get(int i)
{
if(i<picsize)
return s[i];
}
void main()
{
int n=0;
int i=0;
pixel p;
printf("Enter image size:");
scanf("%d",n);
image img1(n);
image img2;
printf("How many pixels:");
scanf("%d",n);
while (i<n)
{
printf("Enter Red number:");
scanf("%d",p.R);
printf("Enter Green number:");
scanf("%d",p.G);
printf("Enter Blue number:");
scanf("%d",p.B);
img1.Set(p,i);
img2.Set(p,i++);
}
printf("Enter pixel number:");
scanf("%d",i);
p=img1.Get(i);
if (p.R==255 && p.G==255 && p.B==255)
printf("This pixel is black!");
}