-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathincresArr.cpp
109 lines (75 loc) · 1.87 KB
/
incresArr.cpp
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
srand(time(0));
printf ("This program print the array in increasing order and only array 3 is Change with Random number\n");
int i, size, sorts, des , z;
int min=1, max =100;
//int Even, Odd,zeros=0;
printf ("Enter size of the array: ");
scanf ("%d", &size);
int winner[size];
printf ("\n\n");
if(size > 0) //to check for empty set
{
for (i=0;i<size;i++) // to insert element in array
{
printf ("Please Enter %d element table\t", i+1);
scanf ("%d", &winner[i]);
}
printf("\nElementy table:\n"); // to print element in array
for (i=0; i<size; i++)
{
printf("winner Element[%d]=%d\n", i+1, winner[i]);
}
//To alter the element 3 alone.
for(int scanner =1; scanner <= 100; scanner++)
{
z= rand() %100 +1;
}
//printf("winner Element[3]= %d\n", z);
//Sorting by increasing
for (i=0; i<size; i++)
{
for (sorts=i+1; sorts<size; sorts++)
{
if (winner[i] >winner[sorts])
{
des= winner[i];
winner[i] = winner[sorts];
winner[sorts] = des;
}
}
}
printf("\nAlternate element in index[3] with random number\n");
printf("Arrange in Ascending order of elements\n");
printf("\n");
// the below commentted code can also be use for the alternating element in index 3
/*
winner[2]=z; //index 3
for(i=0; i< size; i++)
{
if (winner[i] ==z)
{
printf("winner Element[3]= %d\n", z);
continue;
}
printf("winner Element[%d]= %d\n", i+1, winner[i]);
}
*/
for(i=0; i< size; i++)
{
if ( i+1 ==3)
{
printf("winner Element[3]= %d\n", z);
continue;
}
printf("winner Element[%d]= %d\n", i+1, winner[i]);
}
}
else
printf("This is an empty Set");
return 0;
}