C language: outputs the scores of each student in a two-dimensional array using pointer functions. The pointer is a two-dimensional array.

Source: Internet
Author: User

C language: outputs the scores of each student in a two-dimensional array using pointer functions. The pointer is a two-dimensional array.

//

// Main. c

// Pointer_function

//

// Created by ma c on 15/8/2.

// Copyright (c) 2015 bjsxt. All rights reserved.

// Requirement: when a student ID is input through the pointer function, the corresponding Student Score is displayed on the console.

 

# Include <stdio. h>

Float * search (float (* p) [4], int n) // float (* p) [4] is an array pointer, the first line pointing to the two-digit array with four float Elements

{

Float * pt;

Pt = * (p + n );

Return pt;

}

Int main (int argc, const char * argv [])

{

Float score [] [4] = {99,98, 97,99}, {88,97, 96,96}, {96,95, 93,90 }};

Int sno;

Printf ("please input sno is (0, 1, 2 ):");

Scanf ("% d", & sno );

Float * p = search (score, sno); // call the pointer function and return a pointer.

For (int I = 0; I <4; I ++)

{

Printf ("%. 1f", * (p + I); // traverses the result of each row

}

Printf ("\ n ");

Return 0;

}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.