Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

An example Analysis of C language structure body Array

Shulou Source: shulou.com Published: 2022-05-31 14:30:29 09月17日 Update

In this article, the editor introduces "c language structure body array example analysis" in detail, the content is detailed, the steps are clear, and the details are handled properly. I hope this article "c language structure body array example analysis" can help you solve your doubts. Let's follow the editor's ideas to learn new knowledge.

An example of structure array program

Ex.: election voting procedure. There are three candidates to participate in the election, the number of voters is n, each person can only cast one vote, enter the number n and the candidate name of each candidate from the keyboard, count and output the number of votes of each candidate.

# include

# include

Struct candicate / / defines the structure type of the candidate

{

Char name [20]; / / name

Int count; / / number of votes obtained

}

Int main ()

{

Struct candicate cand [] = {"zhang", 0, "li", 0, "wang", 0}

Int n,i,j

Char name [20]

Printf ("Please enter the number of voters:")

Scanf ("d", & n)

Printf ("enter candidate names for all [% d] voters:\ n", n)

For (iTunes 1)

Tags: Voting structure array candidate election language analysis name number of people article input content number of votes voter procedure proper candidate name idea situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi MySQL Docker Huawei