C language array exercises

Source: Internet
Author: User

C language array exercises

//// Main. c // array // Created by Qiu xuewei on 15/7/7. // Copyright (c) 2015 Qiu xuewei. all rights reserved. // # include
  
   
# Define N 10 // 7, symmetric // typedef enum {// false, // 0 // true // 1 //} bool; // bool isSymmetryArray (int a [], int len); // bool isSymmetryArray (int a [], int len) // {// for (int I = 0; I
   
    
= 0; I --) {// printf (% c, array [I]); //} // 5. enter ten positive integers and sort these 10 numbers in ascending order. // int num [10]; // int I, temp = 0; // printf (input 10 positive integers :); // for (I = 0; I <10; I ++) {// scanf (% d, & num [I]); //} // for (I = 0; I <10; I ++) {// for (int j = 0; j <10-i-1; j ++) {// bubble sort // if (num [j]
    
     
{,} // Int array1 [10] = {,}, array2 [10]; // for (int I = 0, j = 5; I <5 & j <10; I ++, j ++) {// array2 [I] = array1 [j]; // array2 [j] = array1 [I]; //} // for (int j = 0; j <10; j ++) {// printf (% d, array2 [j]); //} // 7. checks whether an integer array is a symmetric array, for example, {, 3,} and, 1} are symmetric arrays // int a [] = {, 2}; // int B [] =, 1, 1}; // if (isSymmetryArray (B, 8) = true) {// printf (duichen); //} else {// printf (buduichen ); ///} // 8. given an integer array of 10 elements, delete the first element, and move the following array order forward. // int a [10] = {2nd, 9, 0}, I; // for (I = 1; I <9; I ++) {// a [I] = a [I + 1]; //} // for (I = 0; I <10; I ++) {// printf (% d, a [I]); ///} // 9. given an integer array, calculate the subscript of the second largest number in the array ///// int a [N] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; // int max = 0, secMax = 0, I, j; // maximum value, second largest value, variable, store second largest number subscript // for (I = 0; I
     
      
Max) {// max = a [I]; //} // for (I = 0; I
      
        SecMax & a [I]
       
         Avg) {// num ++; //} // printf (the number of averages in this array is % d, num ); /// // 11. given an integer array, find the minimum value in the array and put it in the first element of the array, put the content of the original first element in the element where the minimum value is located //// int a [N] = {1, 2, 4, 5, 6, 7, 8, 9, 0 }; // int min = a [0], m = 0; // minimum value, minimum subscript // int I; // for (I = 1; I
        
          "45123", assuming that the number of characters in the character array is greater than 2 // int a [N] = {1, 2, 4, 5, 6, 7, 8, 9, 0 }, B [N]; // int I, j; // obtain the value of the first two numbers. // for (I = 0; I <2; I ++) {// B [I] = a [N-2 + I]; //} // for (I = 2, j = 0; I
         
           = 0; I --) {// scanf (% d, & num [I]); //} // for (j = 0; j
          
            2 6 2 7 // 3 2 5 9 3 7 5 2 // 4 7 2 3 4 8 9 3 // const int n = 4; // int num1 [n] [n] = {1, 2, 3, 4}, {5, 6, 7, 8}, {3, 2, 5, 9}, {4, 7, 2, 3 }}; // int num2 [n] [n], I, j; // for (I = 0; I
           
             = 0; j --) {// if (I = 0 | j = 0) {// triangle [I] [j] = 1; //} else {// triangle [I] [j] = triangle [I-1] [J-1] + triangle [I-1] [j]; ///} // for (I = 0; I
            
              = 0; j --) {// printf (% d, triangle [I] [j]); //} // printf (); ///} // 20. assign a value to an integer array. The assignment rules are as follows. The submark can be assigned 1 for all the three divisible values and 2 for all the five divisible values, values of all values that can be divisible by 7 are 3, and values of other values are 0 // int m = 22; // int shuzu [m]; // int I; // shuzu [0] = 0; // for (I = 1; 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.