Blue Bridge Cup - Basic questions 01

Problem Description
  Given a length of n number of columns, this number of columns arranged in large ascending order. 1 <= n <= 200
input format
  first line an integer n.
  The second line contains n integers, the number to be sorted, each of the integer absolute value of less than 10,000.
Output format
  output line, the number of columns in ascending order of the sorted output.
Sample input
. 5
. 8. 4. 3. 6. 9
Sample Output
34689
code is as follows:

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int i, j, n, m=0;
	int arr[200];
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	for(i=0;i<n;i++){
		for (j=i+1;j<=n;j++){
			if(arr[i]>arr[j]){
				m=arr[j];
				arr[j]=arr[i];
				arr[i]=m;				
			}
		}
	}
	for(i=0;i<n;i++)
		printf("%d ",arr[i]);
	
	return 0;
}

Tips:
the game must pay attention to see the subject meaning, especially for some of the details that need extra attention, such as the subject of the request does not have to add additional text formatting when the input and output, and therefore Do not gild the lily

Guess you like

Origin blog.csdn.net/weixin_44566432/article/details/88687377