current position:Home>How to store subscripts in array in C language
How to store subscripts in array in C language
2022-02-02 19:50:47 【CSDN Q & A】
Write a program to complete the following functions :
1) Find a two-dimensional array arr A specific value in value, The return value of the function is the number of occurrences of its value ,location Array value Position of appearance
int findValue(double arr[][3], int num, double value, int location[][2])
2) Calling function in main function , And output the result
Refer to the answer 1:
int findValue(double arr[][3], int num, double value, int location[][2]){ if (num < 0) { return -1; } int i, j, m = 0, n = 0;; int r = num / 3; if (num % 3 == 0) { r = num / 3; } else{ r = num / 3 + 1; } for (i = 0; i < r; i++) { for (j = 0; j < 3; j++) { if (value == arr[i][j]) { location[m][0] = i; location[m][1] = j; m ++; n ++; } } } return n; }#include<stdio.h>int main(){ double arr[200][3]; int n, i, location[200][2]; printf(" Please enter the number of array elements :\n"); scanf("%d", &n); if (n <= 0) { return -1; } printf(" Please enter an array element :\n"); for (i = 0; i < n; i++) { scanf("%lf", &arr[i/3][i%3]); } int c = findValue(arr, n, 0.52, location); printf("%lf appear %d Time , The positions are :\n", 0.52, c); for (i = 0; i < c; i++) { printf("(%d, %d):\n", location[i][0], location[i][1]); } getchar(); return 0;}
Running results :
Refer to the answer 2:
copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021950448451.html
The sidebar is recommended
- How to set a draw when making tic tac toe chess in Python
- Solving Python language C language
- How does Maple set a variable to be any integer from a certain interval
- How to realize that the opening of a website computer is one interface and the opening of a mobile phone is another interface, similar to self adaptation?
- After entering two indefinite length arrays and sorting them, merge and sort the two arrays again
- The computer has a web, but it can't access other web pages except the navigation page display
- C + + how to do this program
- Want to know how to find the parameters of this function? How should the matlab code knock
- Multi module project cannot inject mapper java
- MapReduce average score how to find the average of each line
guess what you like
-
Wechat applet rendering layer error
-
What does this mean? Why can't I open my QQ
-
CMD run Py file encountered a problem
-
Help me see what's wrong
-
Why not 13bingo
-
Decipher the password and there is no result after running?
-
Ask you why this code can't run (◞‸◟)
-
Hello, can you extract the of our applet
-
Why not show folders when attaching a database
-
How can the last line end with 0 without spaces
Random recommended
- Generate images from HTML pages and download them into PDF files
- Two Python experiment questions
- Hidden display problems in HTML
- Is there any good analysis process for push box problem
- What's going on here?.,!
- Cyclic input and output. If the input is a number, it will print. If the input is not a number, it will print No
- C language freshman PTA input an English sentence, change the first letter of each word into capital letters.
- Question e: snake walking, please help me
- Why is the attenuation of wave height in numerical simulation serious?
- Difference between digital image processing and image signal processing (ISP)
- Oracle a column of multi value update problem.
- Write a program in Python.
- How can Python write here to become a variable
- Which rstudio is installed in win7 64 bit? Dear friends, the previous connection can install w10,8,7, but now it can only install W10. Cry.
- Which is better, CCD camera tracking or gray sensor tracking
- Virtual reality combined with AR space
- How to click two label controls in QT to subtract the customized numbers in the control
- Ask you why there is a period of garbled code in front of the output?
- QR code generation of shopping scanning payment and third-party payment
- The Internet is a large network composed of many small networks. Can a local area network also be such a small network? What's more, how large is the coverage of a small network in a large network?
- Write a function to randomly generate an array of length n with elements from 0 to 99
- I don't understand very well. Can you explain it?
- Help me look at the code (I'm just a freshman, so I only know C). Why the bill The data in txt will always become 0 (after each command 1 is executed and more than one order is entered, only the last order in txt is saved, and all the others become 0) (o
- After the Ubuntu language is switched to English, two desktops appear
- Ora-01555 snapshot is too old. Fallback segment number (name) is too small. Ora-22924 snapshot is too old
- Win10 system boot unlimited automatic repair, recycling the use of Baidu methods are invalid
- A node of database RAC cannot be accessed normally
- Android SDK does not have uiautomatorviewer Bat file
- How should this program be completed
- One to many query of mybatis. The query conditions are in multiple parties. PageHelper paging is integrated. How can this XML be better implemented
- Error in NPM run dev: unknown option '-- inline'
- Java database: error caused by: Java lang.ClassNotFoundException: Didn't find class 'java. sql. Sqltype 'problem, how to solve it?
- What attachments do SQL server send mail with?
- In the built-in browser in windows, if you can't open the direct search web page, you can open the web page by using the web address. How to solve it?
- Tomcat failed to start. Would you like to see help
- How does the StrCmp function compare string sizes? What is the method
- Find the first 30 numbers of sequence 1 1 2 3 5 8 13 21
- Java finds array elements of the specified type
- Vue3 uses Axios to request JSON files in the public folder, and there is always a 500 error!
- Is a graphic inheritance problem