Want to comb the hands

Source: Internet
Author: User

(1) Use the function to find the largest value of a, B and in the order of large to small output

int MAX (int a,int b,int *p,int *q)

{

p=&a;//to write in the main function, the reason is not clear ... Anyway, to write the answer here is wrong, change to the main function is right, and can only define a main function or call function

q=&b;

if (a<b)

{

int c=a;//Anyway, *p is a, it's not standard, but it's right.

*p=b;

*q=c;

}

return A;

}

#include <stdio.h>

int main ()

{

int MAX (int a,int b,int *p,int *q)

int A, B;

int *p,*q;//should be int *p=a,*q=b;

Max (A,B,P,Q);

scanf ("%d%d", &a,&d);

printf ("%d\n", a);

printf ("%d%d", A, b);

return 0;

}

Error code, correcting://

Note: The definition is always *p, when called with P;

int *p=&a==int *p; p=&q;

Modified version:

If you change to a global variable:

Looks like me. The calling function is not on the front, and the global variable is best capitalized;

Suddenly think of a # define IP 3.14

(2) pointers and one-dimensional arrays

1.A[5] Output

#include <stdio.h>

int main ()

{

int a[5]={0,1,2,3,4};

int *p=a;//Note and the preceding difference int *p=&a; is the definition pointer p,p as address, the address is &a; but really should be int *p;int p=&a; But here, a represents the first address of a[5]

for (;p <a+5;p++)

printf ("%d", *p);

}

Want to input plus output

I don't know what's wrong, woo-hoo.

I came back and changed the wrong way.

Note that the current value of the pointer variable precedes the previous one that has been added to the a+5

Change the following, this is correct

Looks like I just saw this kind of.

Typical error

A is a constant cannot be ++;p a variable

Improved

P++;*p = = *p++ ==* (p++) ==a[i++]* and + + are the same priority, right-to-left, forget, later in the order of confusion, with parentheses

It's not too early to write tomorrow.

Want to comb the hands

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.