Array of strings

Source: Internet
Author: User

There are 3 country names, find the first alphabetical string in the country

The code is as follows:

#include <iostream> #include <string>using namespace Std;int main () {    void smallest_string (char str[] 30],int i);//function declaration    int i;    Char country_name[3][30];//defines a two-dimensional character array, which has a two-dimensional character array as 3 one-dimensional character arrays, each of which has 30 elements for    (i=0;i<3;i++)    cin>> Country_name[i];    Smallest_string (country_name,3);    Call the Smallest_name function to pass the character array name to the parameter    return 0;} void Smallest_string (char str[][30],int n) {    int i;    Char string[30];    strcpy (String,str[0]);   Daleitai algorithm for    (i=0;i<n;i++)        if (strcmp (str[i],string) <0)        strcpy (String,str[i]);    cout<<endl<< "The smallest string is:" <<string<<endl;    }

Note: You can compare characters in any situation whenever you change some of the parameters of this function.

Copyright NOTICE: This article is my original article, we can reprint Oh!!

Array of strings

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.