D
D
Deckers2022-03-05 20:18:31
C++ / C#
Deckers, 2022-03-05 20:18:31

How to work with an address in an array?

Hi everyone, can you explain what is the difference between these spellings? Specifically, I want to work with the address of the cell and not just its value, swap, etc.

#include <stdio.h>

int main()
{
int n, a[n], i;
int min, max;
printf("Введите n: ");
scanf("%d", &n);
for(i = 0; i < n; i++) {
    printf("a[%d] = ", i);
    scanf("%d", &a[i]); 
    max = a[0], min = a[0];}

for(i = 0; i < n; i++){
    if(a[i] > max) { max = a[i]; }
    if(a[i] <= min) { min = a[i]; } }
printf("\nMax: [%d] \nMin: [%d] \n", max, min);
printf("%d %d", a[max], a[min]);
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question