Skip to content

Instantly share code, notes, and snippets.

@rainbow23
Created May 29, 2017 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rainbow23/5e67baa9c8fc0873e1531c8b7714ac6f to your computer and use it in GitHub Desktop.
Save rainbow23/5e67baa9c8fc0873e1531c8b7714ac6f to your computer and use it in GitHub Desktop.
paiza D rank
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
// 自分の得意な言語で
// Let's チャレンジ!!
char str[100];
fgets(str, sizeof(str), stdin);
int allnum = atoi(str);
int array[100];
for(int c1=0; c1<allnum; c1++)
{
char eachNumChar[10];
fgets(eachNumChar, sizeof(eachNumChar), stdin);
int eachNum = atoi(eachNumChar);
//printf("eachNum = %d\n", eachNum);
array[c1] = eachNum;
}
for(int c1 = 0; c1 < allnum; c1++)
{
for(int c2 = allnum -1; c2 > c1; c2--)
{
if(array[c2] < array[c2-1] )
{
int tmp = array[c2-1];
array[c2-1] = array[c2];
array[c2] = tmp;
}
}
//printf("\n");
}
for(int c1 = 0; c1 < allnum; c1++)
{
printf("%d\n", array[c1]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment