In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the C language how to delete an array value, the article is very detailed, has a certain reference value, interested friends must read it!
1. Preface
Idle at home or idle, these days have witnessed the power of various data structures of Python. The data types in Python, such as lists, tuples, dictionaries and so on, have their own characteristics. There is no need to set the length of the list, we can insert elements randomly, and the type of elements is arbitrary.
Perhaps this is the power of object-oriented languages. C, as a process-oriented language, is naturally not as powerful as Python. Learning C language without pointers and structures is really impossible. It is very difficult to use C language for string processing in CCF exams, but it is easy to use an object-oriented language such as C++.
2. Delete the elements in the array
In python, we can easily delete specific elements using the following methods:
Lang = ["Python", "C++", "Java", "PHP", "Ruby", "MATLAB"] # use positive index del lang [2] print (lang)
However, everything in C language has to be built on its own. The first experiment in learning data structures is related to sequential table processing, and this is one of the operations introduced here.
Here we can define a function with the array name and the array length as arguments:
Void del_element (int arr [], int n) / / n is the number of elements in the array
Although the length of the array needs to be given by ourselves, we do not need to directly write out the specific number of elements, but directly assign values to the array first.
Int arr [] = {1, 4, 5, 7}
Since we want to delete the elements in the array, we must first know which elements are in the array. At the same time, you also define a variable and assign the element that needs to be deleted to that variable.
Int delect=0; printf ("Array before delete operation:\ n"); for (int k = 0 * * k
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.