Enter a set of numbers with a pointer, find the largest number among them, and swap the largest numb

Updated on educate 2024-04-05
6 answers
  1. Anonymous users2024-02-07

    #include

    main()

    int i,a[9],temp,*pmax=0;

    for(i=0;i<9;i++) *Array subscripts cannot be crossed * scanf("%d",&a[i]);

    if(a[i]>*pmax)*pmax=a[i];

    printf("%d",*pmax);*After the comparison is completed, it can be output, if it is placed at the end, the output may not be the maximum*

    if(*pmax!=a[0]) *Compare value, not compare address * temp=*pmax;

    pmax=a[0];

    a[0]=temp;

  2. Anonymous users2024-02-06

    void main()

    int i,a[9],temp,*pmax=&a[0];

    for(i=0;i<9;i++)

    scanf("%d",&a[i]);

    if(a[i]>*pmax)*pmax=a[i];

    if(pmax!=&a[0])

    temp=*pmax;

    pmax=a[0];

    a[0]=temp;

    printf("%d",*pmax);

    The initialization pointer can no longer be defined, and the pointer space cannot be directly assigned, so the space must be requested.

  3. Anonymous users2024-02-05

    Visually at a loss ......It is recommended that you do not assign a value to the pointer.

    for(i=0,*pmax=i;i<10;i++) This one is better, right?

    Instead, separate the loop from the input ... ...... with two loops

  4. Anonymous users2024-02-04

    Your A length is 9, but your loop is 10

  5. Anonymous users2024-02-03

    Method 1: (Using the Comparative Method).

    Method 2: (using the foaming method).

    Method 3: (Modular design with functions).

  6. Anonymous users2024-02-02

    Analysis: Since we talk about swaps, these 15 numbers vary.

    The algorithm steps are as follows:

    1.Put the integer into the one-dimensional array a;

    2.Copy the integer into another array b and sort it by the sorting algorithm to get the second largest number and the second decimal number.

    3.The obtained sub-largest and sub-decimal numbers are assigned to x and y, respectively.

    4.In array a, x is found and replaced with y, and y is found and replaced by x;

    5.Output array a, end.

    Corrections are welcome!

Related questions
14 answers2024-04-05

Il DIVO profile ** from CCTV).

This "men's classical quartet" is called "il divo", which means "opera hero" and "extraordinary performer". Does the melody of their title song sound familiar? The title song called "Don't Break My Heart" is based on the 1995 song of the same name by black female singer Tony Blackton. >>>More

5 answers2024-04-05

1. Self-improvement and self-reliance are the prerequisites for success;

14 answers2024-04-05

1. I swear (584), I will go out with you (5682177778), love with you (12234), go together (1798), go for a walk (76868), I don't want to be with you (587129955), being loved is happiness (829475). >>>More

5 answers2024-04-05

Gratitude is a rainbow that flies in the sky, so that people with gloomy eyes can see the beauty of the world. >>>More

13 answers2024-04-05

The first item: half-squat jump.

1. At the beginning, half-squat to? 2. Jump up at least 20 to 25cm from the ground. (If you find it easy, you can jump to 25 to 30cm). When in the air, keep your hands behind your back. When you land, finish it once. >>>More