current position:Home>Input n integers from the keyboard and store them in a pile of arrays. Put all positive numbers in the array in front of the array and negative numbers in the back to output the array
Input n integers from the keyboard and store them in a pile of arrays. Put all positive numbers in the array in front of the array and negative numbers in the back to output the array
2022-02-03 00:33:37 【CSDN Q & A】
Refer to the answer 1:
#include "stdio.h"#define N 100int main(){ int a[N],i,j,temp,n; scanf("%d",&n); if(n>100) return 0; for(i=0;i<n;i++){ scanf("%d",&a[i]); } for(i=0;i<n-1;i++){ if(a[i]<0){ for(j=i+1;j<n;j++){ if(a[j]>0){ temp=a[j]; a[j]=a[i]; a[i]=temp; break; } } } } for(i=0;i<n;i++){ printf("%d ",a[i]); } return 0;}
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/202202030033359491.html
The sidebar is recommended
- How to use stu method to input student names and grades in pyton and store them in the list
- If you enter the title of a book, the length of each title is no more than 100, and the books are sorted in ASCII order from small to large. Enter the number of book titles indefinitely until the end of the document. Sort the string from small to large ac
- Python selenium loading is slower than opening the web card normally. Is there any solution
- When the database connection is normal, it is impossible to add, delete, modify and query the data in the database
- How to realize NS3 traffic load distribution
- How to enter the grades of each subject? Do you need a two-dimensional array for each subject
- Please answer what this is
- How to define and initialize structures in. H
- In C language, the input content is larger than the defined array, but can it be output?
- The running result is not expected (c + +)
guess what you like
-
matlab . Image pixel processing
-
The process of solving these more than 2000 functions through subs is too slow
-
Longest common prefix, binary search problem
-
Basic HTML5 code table and usage
-
Error is reported after Vue project is started. Please ask for help
-
How can I open the database in the examinee's folder for computer level 2 MySQL test questions?
-
The following program (function) deletes the characters exactly the same as the string S2 in the string S1, such as S1: China S2: in, and the result is cha
-
Why NP The empty ((3,2)) element is not random?
-
Why do you report an error? Find a solution
-
Using C + + and pcap H and iphlpapi H. how to solve the problem?
Random recommended
- How can I fix the problem of uploading to idea
- com. fasterxml. jackson. databind. Objectmapper throw exception
- What is the reason and how to solve it
- Preparestatement of javajdbc
- int x=8,y=12,z=14 ; x++,y=z++,z=++x; y=x%z- -; Find the value of XYZ
- Why is this the case when I access the PHP test program under localhost in MacOS?
- Why should this code be int & n instead of int n? In C + +, under what circumstances do you need to be int & n
- The redis session problem runs well locally. As soon as it arrives online, it crazy reports exceptions. It starts to report when it starts. And the function can be used normally
- Research on Professional Course Scheduling Based on nonlinear programming
- The question about C + +: that's it: include 'Einstein h'
- Sqlyog failed to import the database. I don't know what to do
- The Microsoft edge browser can only enter the address in the address bar and cannot search
- Why can't data be saved when text is written in this way?
- When the user logs in and out, a socket error is reported when he logs in again
- The website editor cannot be right-click pasted and cannot be used
- On the problem of multi-threaded ball taking and putting (language Java)
- Start the flume script and report an error in the generated log file: agent configuration for 'A1' has no configfilters
- What can reflect the professional quality of a yard farmer?
- Why is the returned hour, minute and second Nan
- Python, C problem - leap year judgment
- SQL. Why not attach it, as shown in the figure
- How does robotjs set automatic rebuild in electronic build
- Python final exam SOS
- I admit that I have degenerated, but I still want to know how to solve Java
- I have encountered several array problems in C + +. I hope the big God can solve the puzzle. It's best to have comments
- Why is it double? don't get it
- C language novice village, high adoption rate
- The usage and law of this function are expected to be explained.
- Let's see what's wrong. My code will output one less country
- Why is the average 0
- The replacement of tab key in hive leads to a problem in the file.
- Now to realize a function, use the El tree component of element UI, select the relevant node, and then copy a new tree with only relevant parent-child nodes below.
- Sqlyog database import failed with the following error. Do you know
- How do two lists compare in the same location
- How to group the following data by film and television, education, music, E-sports and other sectors
- Server socket + Android socket can only send a message once after connecting. The second sending does not respond. You need to reconnect the socket and solve it
- Questions about student information management system C++
- Qtable widget of QT double click to edit and display the problem
- Separate strings and insert a comma for each 5 characters
- QT qtablewidget double click to modify the content. What is the problem