C Language -- Function

Source: Internet
Author: User

# Import
 
  
# Import "MyFunction. h "# import" Operator. h "# define PI 3.1415926int mediumValue (int o, int p, int q) {# pragma mark ------------- summarize several methods for finding the number of intermediate numbers // sum the three numbers, minus the largest, minimum // array sorting // first method // calculate the maximum first, then the minimum, and finally the int max = 0, min = 0, med = 0; if (o> p & o> q) {max = o;} else if (p> o & p> q) {max = p ;} else {max = q;} if (o
  
   
P & o
   
    
Q) {med = o;} else if (p> o & p
    
     
Q) {med = p;} else {med = q;} return med;} // No return value. No parameter void printfLanou (void); void printfLanou (void) {printf ("blue ou") ;}// no return value. The parameter void printfNum (int number); void printfNum (int number) {printf ("% d ", number);} // There is a returned value, no parameter // float PI () // {// return 3.1415; //} // There is a returned value, there are also parameters // int square (int x) // {// return x * x; //} // sum int sumsValue (int m, int n ); int sumsValue (int m, int n) {int sums = 0; for (int I = m; I <= n; I ++) {Sums = sums + I;} return sums;} int main (int argc, const char * argv []) {// int B [10] = {0}; // for (int I = 0; I <10; I ++) {// B [I] = arc4random () % (20-10 + 1) + 10; //} // for (int j = 0; j <10; j ++) {// printf ("% d", B [j]); // int c [5] = {0 }; // for (int I = 0; I <5; I ++) {// c [I] = arc4random () % (60-20 + 1) + 20; //} // printf ("\ n"); // for (int I = 0; I <5; I ++) {// printf ("% d ", c [I]); // printfLanou ();// PrintfNum (5); // printf ("% f", PI () + 3); // printf ("% d", square (5 )); // printf ("% d", sumsValue (); // int a [5] = {, 9}; // bubbleSort (, 5); # pragma mark -------- summarize the array functions // array as the parameter, passing in the array name, that is, the first address of the array // once the array is created, there will be a fixed address, you cannot operate the entire array. You can only operate on an element in the array. // functions can be nested and called, but cannot be nested. // 1. write the int sumValeu (int n) function. Calculate the sum of 1 to n. // int a = 0; // a = sumValue (101); // printf ("% d ", a); // 2. write the function dayOfYear (Year, month, day) // printf ("\ n"); // dayOf Year (2014, 1, 13); // 3. write a function and return the intermediate number of three integers // int mediu = mediumValue (2, 3, 1); // printf ("mediu = % d", mediu); // 4, compile a function and return the number of numbers in positive integer n. // method-// numbers (345); // method 2 (while LOOP) // 5. create? Right? Module: operator. h operator. m // implement the function to add, subtract, multiply, and divide two integer values. // Add (1, 2); // subtract // multiply // except // 6. Calculate s = (2*2 )! + (3*3 )! + (4*4 )! // 1. What is the sum of integer values? // 2 ,? Integer factorial // 3. What is the sum of three integers? Of the factorial and // square (2); // printf ("square % d", square (2 )); // factorial (square (2); // printf ("factorial % d", factorial (square (2 ))); // sum // int s = 0; // first // s = sum (factorial (square (2), factorial (square (3 )), factorial (square (4); // second // for (int I = 2; I <= 4; I ++) {// s = s + factorial (square (I); //} // s = factorial (5); // printf ("\ n "); // printf ("s = % d", s); # pragma mark -------- summary static // same function type, same return value, same number of parameters // (post-runtime, during compilation) // all variables defined in the function are local variables // without static modification, the runtime is placed in the stack area, and the destroy is used up // static modification is available, the compilation phase is already in the static zone, which occupies a lot of memory and can only be initialized once // The function modified with static is used, you can only use the // NTFS plug-in // for (int I = 0; I <10; I ++) {// test () in this file (); //} return 0 ;}
    
   
  
 


"Operator.h"
// Add void add (int a, int B); // subtract void reduce (int a, int B); // multiply void multiply (int a, int B ); // except void divide (int a, int B); void test ();
"Operator.m"

// Add void add (int a, int B) {printf ("% d", a + B);} // subtract void reduce (int a, int B) {printf ("% d", a-B);} // multiply void multiply (int a, int B) {printf ("% d", a * B );} // except void divide (int a, int B) {printf ("% d", a/B) ;}# pragma mark ------- static keyword void test () {// static int I = 10; int I = 10; printf ("% d", ++ I );}
MyFunction.h

Int sumValue (int n); void dayOfYear (int year, int month, int day); int mediumValue (int o, int p, int q); // Bubble sorting, arr is the array to be sorted, and count is the number of arrays void bubbleSort (int arr [], int count ); // help me write a random number function // The number of digits in positive integer n void numbers (int n); // square int square (int x ); // factorial int factorial (int n); // sum int sum (int a, int B, int c );
MyFunction.m

Int sumValue (int n) {int sum = 0; for (int I = 1; I
  
   
2) {days = days + 1 ;}}days = days + day; printf ("day % d", days) ;}// Bubble sorting, arr is the array to be sorted, and count is the number of arrays void bubbleSort (int arr [], int count) {for (int I = 0; I
   
    
Arr [j + 1]) {int temp = arr [j]; arr [j] = arr [j + 1]; arr [j + 1] = temp ;}}} printf ("\ n"); for (int I = 0; I
    
     





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.