C
- voluntas
- @ignis_fatuus
- ブン
- @Linda_pp
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- takezoh
- まろ
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- I (@wx257osn2)
- Tommy6
- @tyottyoworks
- ___shanon
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
90
1
// Online C compiler to run C program online
2
3
4
5
void initialize (int *size, int ar[]);
6
void insert (int max, int *size, int ar[], int num);
7
void iremove (int *size, int ar[], int num);
8
void display (int size, int ar[]);
9
10
11
int main ()
12
{
13
int option = 0;
14
int num, ar[MAX], size = 0;
15
16
printf ("Please select an option: \n");
17
printf ("(1) Initialize the array \n");
18
printf ("(2) Insert an integer \n");
19
printf ("(3) Remove an integer \n");
20
printf ("(4) Display the numbers stored in the array \n");
21
printf ("(5) Quit \n");
22
23
do
24
{
25
printf ("Enter your choice: \n");
26
scanf ("%d", &option);
27
switch (option)
28
{
29
case 1:
30
initialize (&size, ar);
31
break;
32
case 2:
33
printf ("Enter an integer: \n");
34
scanf ("%d", &num);
35
insert (MAX, &size, ar, num);
36
break;
37
case 3:
38
break;
39
case 4:
40
display(size,ar);
41
break;
42
default:
43
break;
44
}
45
}
46
while (option < 5);
47
return 0;
48
}
49
50
void display (int size, int ar[])
51
{
52
int i;
53
printf ("The %d numbers in the array: \n", size);
54
for (i = 0; i < size; i++)
55
printf ("%d ", ar[i]);
56
printf ("\n");
57
}
58
59
void initialize (int *size, int ar[])
60
{
61
int total, i, num;
62
printf ("Enter the total number of integers (MAX=%d): \n", MAX);
63
scanf ("%d", &total);
64
(*size) = 0;
65
printf ("Enter the integers: \n");
66
for (i = 0; i < total; i++)
67
{
68
scanf ("%d", &num);
69
insert (MAX, size, ar, num);
70
}
71
}
72
73
void insert (int max, int *size, int ar[], int num)
74
{
75
if(*size>=MAX)
76
{
77
printf("Array full");
78
}
79
else
80
{
$ gcc prog.c -Wall -Wextra -std=c99 -pedantic
Stdin
1 5
11 22 33 44 55
2 334
4
5
Start
prog.c: In function 'insert': prog.c:73:22: warning: unused parameter 'max' [-Wunused-parameter] 73 | void insert (int max, int *size, int ar[], int num) | ~~~~^~~ prog.c: In function 'iremove': prog.c:86:24: warning: unused parameter 'size' [-Wunused-parameter] 86 | void iremove (int *size, int ar[], int num) | ~~~~~^~~~ prog.c:86:34: warning: unused parameter 'ar' [-Wunused-parameter] 86 | void iremove (int *size, int ar[], int num) | ~~~~^~~~ prog.c:86:44: warning: unused parameter 'num' [-Wunused-parameter] 86 | void iremove (int *size, int ar[], int num) | ~~~~^~~
Please select an option: (1) Initialize the array (2) Insert an integer (3) Remove an integer (4) Display the numbers stored in the array (5) Quit Enter your choice: Enter the total number of integers (MAX=10): Enter the integers: Enter your choice: Enter an integer: Enter your choice: The 6 numbers in the array: 11 22 33 44 55 334 Enter your choice:
0
Finish