C language-two-dimensional array, string array, multi-dimensional array

Source: Internet
Author: User

 

<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + PGJyPgo8L3A + CjxwPjxwcmUgY2xhc3M9 "brush: java;"> # import Int main (int argc, const char * argv []) {// int a [2] [3] = {// {, 3, 6} //}; // int a [2] [3] = {1, 2, 3, 4, 5, 6 }; //// print a single element // printf ("% d", a [1] [1]); // The element is not fully assigned, the default value is 0 // int B [2] [3] = {1, 2, 3}, {4 }}; //////// 3 rows and 4 columns of floating point data // float c [3] [4] ={// {2.5}, // {3.3 }, // {2.1, 4.8} //}; // for (int I = 0; I <3; I ++) {// for (int j = 0; j <4; j ++) {# pragma mark ---------------------- % g scientific notation, retain the decimal number, remove the // % g scientific notation after 0, retain the decimal number, remove // printf ("% g", c [I] [j]) after 0; //} // printf ("\ n "); //}// define an integer with three rows and four columns. The random range is 0-30. // int a [3] [4] = {0 }; // for (int I = 0; I <3; I ++) {// for (int j = 0; j <4; j ++) {// a [I] [j] = arc4random () % (30 + 1); // printf ("% 2d", a [I] [j]); /// printf ("\ n"); //} // exchange rows and columns, put it in a new array // int B [4] [3] = {0}; // for (int I = 0; I <3; I ++) {// for (int j = 0; j <4; j ++) {// B [j] [I] = a [I] [j]; //} // printf ("\ n"); // for (int I = 0; I <4; I ++) {// for (int j = 0; j <3; j ++) {// printf ("%-2d", B [I] [j]); //} // printf ("\ n"); // find the maximum element, and input rows and columns // int max = 0; // for (int I = 0; I <3; I ++) {// for (int j = 0; j <4; j ++) {// if (max0) {// if the j-th string is greater than the j + 1 character string // char temp [20] = {0 }; // define a temporary string to exchange values // strcpy (temp, str [j]); // strcpy (str [j], str [j + 1]); // strcpy (str [j + 1], temp); //} // printf ("\ n "); // for (int I = 0; I <6; I ++) {// printf ("% s", str [I]); // if (maxLength = strlen (str [I]) {// printf ("the longest word is % s, and the length is % lu", str [I], maxLength); //} // 1. swap the rows and columns of a two-dimensional array into a new array. // int a [2] [3] ={// {, 9 }, // {3, 2, 8} //}; // int B [3] [2] = {0}; // for (int I = 0; I <2; I ++) {// for (int j = 0; j <3; j ++) {// B [j] [I] = a [I] [j]; //} // for (int I = 0; I <3; I ++) {// for (int j = 0; j <2; j ++) {// printf ("% d ", B [I] [j]); //} // printf ("\ n"); //} // 2. there is a two-dimensional array of three rows and four columns. Find the maximum value and write the row and column // int a [3] [4] ={// {, 4 }, // {,}, // {,}, // int max = 0; // for (int I = 0; I <3; I ++) {// for (int j = 0; j <4; j ++) {// if (max0) {// strcpy (temp, str [j]); // strcpy (str [j], str [j + 1]); // strcpy (str [j + 1], temp ); ///} // for (int I = 0; I <10; I ++) {// printf ("% s ", str [I]); // converts all characters to uppercase, And the AC code to uppercase: A65, a97, minus 32 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.