回答編集履歴
1
追加
test
CHANGED
@@ -54,6 +54,70 @@
|
|
54
54
|
|
55
55
|
}
|
56
56
|
|
57
|
+
```
|
57
58
|
|
58
59
|
|
60
|
+
|
61
|
+
マイナス入力対応版
|
62
|
+
|
63
|
+
```c
|
64
|
+
|
65
|
+
#include <stdio.h>
|
66
|
+
|
67
|
+
int main(void)
|
68
|
+
|
69
|
+
{
|
70
|
+
|
71
|
+
int n;
|
72
|
+
|
73
|
+
int number[5] = {0};
|
74
|
+
|
75
|
+
int i,j,k;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
printf("5つの数字を入力\n");
|
80
|
+
|
81
|
+
for(i=0; i<5; i++){
|
82
|
+
|
83
|
+
scanf("%d",&n);
|
84
|
+
|
85
|
+
if ( i == 0 ){
|
86
|
+
|
87
|
+
number[i]=n;
|
88
|
+
|
89
|
+
}else{
|
90
|
+
|
91
|
+
for (j=0; j<i; j++){
|
92
|
+
|
93
|
+
if (number[j] < n){
|
94
|
+
|
95
|
+
for (k=4; k>j; k--) number[k]=number[k-1];
|
96
|
+
|
97
|
+
number[j]=n;
|
98
|
+
|
99
|
+
break;
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
if ( j == i ) number[j]=n;
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
printf("1番目に大きい数字は%dです。\n",number[0]);
|
112
|
+
|
113
|
+
if (number[0] != number[1])
|
114
|
+
|
115
|
+
printf("2番目に大きい数字は%dです。\n",number[1]);
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
return 0;
|
120
|
+
|
121
|
+
}
|
122
|
+
|
59
123
|
```
|