2016
#include <stdio.h>
#define maxn 1050
int num[maxn],n,temp;
int main()
{
while(scanf("%d",&n)!=EOF){
if(!n)
break;
for (int i = 0; i < n; ++i) {
scanf("%d",&num[i]);
}
int s = 0;
for (int j = 0; j < n; ++j) {
if(num[s]>num[j])
s=j;
}
temp=num[s];
num[s]=num[0];
num[0]=temp;
printf("%d",num[0]);
for (int k = 1; k < n; ++k) {
printf(" %d",num[k]);
}
printf("\n");
}
}
2017
#include <stdio.h>
#include <string.h>
#define maxn 10500
char s[maxn],n;
int main()
{
while(scanf("%d",&n)!=EOF){
for (int j = 0; j < n; ++j) {
scanf("%s",s);
int l = strlen(s),ans=0;
for (int i = 0; i < l; ++i) {
if(s[i]<='9'&&s[i]>='0')
ans++;
}
printf("%d\n",ans);
}
}
}
2018
#include <stdio.h>
#include <string.h>
#define maxn 10500
int ans[maxn],n;
int main()
{
ans[1]=1;
ans[2]=2;
ans[3]=3;
for (int k = 4; k < 60; ++k) {
ans[k]=ans[k-1]+ans[k-3];
}
while(scanf("%d",&n)!=EOF){
if(!n)
break;
printf("%d\n",ans[n]);
}
}
2019
#include <stdio.h>
#include <string.h>
#define maxn 10500
int num[maxn],n,m,ans;
int main()
{
while(scanf("%d%d",&n,&m)!=EOF){
if(!n&&!m)
break;
for (int i = 0; i < n; ++i) {
scanf("%d",&num[i]);
}
if(m<=num[0]||m>=num[n]){
if(m<=num[0])
ans=0;
else
ans=n;
}
for (int j = 1; j < n; ++j) {
if(num[j-1]<=m&&num[j]>=m)
ans=j;
}
if(ans==0){
printf("%d",m);
for (int i = 0; i < n; ++i) {
printf(" %d",num[i]);
}
printf("\n");
}
else{
printf("%d",num[0]);
for (int i = 1; i < n; ++i) {
if(i==ans)
printf(" %d",m);
printf(" %d",num[i]);
}
printf("\n");
}
}
}
2020
#include<stdio.h>
#include<math.h>
int temp, num[1000];
int main() {
int n;
while (scanf("%d", &n) != EOF) {
if(!n)
break;
for (int i = 0; i < n; i++)
scanf("%d", &num[i]);
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if (fabs(num[i]) < fabs(num[j])) {
temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}
printf("%d",num[0]);
for (int k = 1; k < n; ++k) {
printf(" %d",num[k]);
}
printf("\n");
}
}
2021
#include<stdio.h>
#include<math.h>
int coin[6]={100,50,10,5,2,1},temp;
int solve(int n){
int cnt = 0;
for (int i = 0; i < 6; ++i) {
cnt+=n/coin[i];
n=n%coin[i];
}
return cnt;
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
if(!n)
break;
int ans = 0;
for (int i = 0; i < n; i++){
scanf("%d", &temp);
ans+=solve(temp);
}
printf("%d\n",ans);
}
}
2022
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int n,m,women[1000][1000],ansi,ansj,ans;
int main() {
while (scanf("%d%d",&n,&m)!=EOF){
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
scanf("%d",&women[i][j]);
}
}
ansi=ansj=1;
ans=women[1][1];
for (int k = 1; k <= n; ++k) {
for (int i = 1; i <= m; ++i) {
if(abs(women[k][i])>abs(women[ansi][ansj])){
ansi=k;
ansj=i;
ans=women[k][i];
}
}
}
printf("%d %d %d\n",ansi,ansj,ans);
}
}
2023
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int n,m,grade[1000][1000],ans;
double avest[1000],avesb[1000];
int main() {
while(scanf("%d%d",&n,&m)!=EOF){
double temp = 0;
ans=0;
for (int i = 1; i <= n; ++i) {
temp=0;
for (int j = 1; j <= m; ++j) {
if(i==1)
avesb[j]=0;
scanf("%d",&grade[i][j]);
temp+=grade[i][j];
avesb[j]+=grade[i][j];
}
avest[i]=(double)temp/m;
}
for (int k = 1; k <= m; ++k) {
avesb[k]=(double)avesb[k]/n;
}
for (int l = 1; l <= n; ++l) {
int judge = 0;
for (int i = 1; i <= m; ++i) {
if(grade[l][i]<avesb[i])
judge=1;
}
if(!judge)
ans++;
}
printf("%.2lf",avest[1]);
for (int i1 = 2; i1 <= n; ++i1) {
printf(" %.2lf",avest[i1]);
}
printf("\n");
printf("%.2lf",avesb[1]);
for (int i1 = 2; i1 <= m; ++i1) {
printf(" %.2lf",avesb[i1]);
}
printf("\n");
printf("%d\n",ans);
printf("\n");
}
}
2024
#include<stdio.h>
#include<string.h>
int main() {
int s, len,sum;
char str[100];
scanf("%d", &s);
getchar();
while (s--) {
sum = 0;
gets(str);
len = strlen(str);
if (str[0] >= '0' && str[0] <= '9')
printf("no\n");
else {
for (int i = 0; i <= len - 1; i++)
if (str[i] >= '0' && str[i] <= '9' || str[i] >= 'a' && str[i] <= 'z' ||str[i] >= 'A' && str[i] <= 'Z' || str[i] == '_')
sum++;
if (sum == len)
printf("yes\n");
else
printf("no\n");
}
}
}
2025
#include <stdio.h>
#include <string.h>
char s[105];
int main()
{
char max;
while(scanf("%s", s) != EOF) {
max = s[0];
int l = strlen(s);
for(int i=0; i < l; i++)
if(s[i] > max)
max = s[i];
for(int i=0; i < l; i++) {
printf("%c", s[i]);
if(s[i] == max)
printf("(max)");
}
printf("\n");
}
}
2026
#include <stdio.h>
#include <string.h>
int main() {
char s[102];
while (gets(s) != NULL) {
if (s[0] != ' ')
s[0] -= 32;
for (int i = 1; i < strlen(s); i++) {
if (s[i] == ' ') {
s[i + 1] = s[i + 1] - 32;
continue;
}
}
puts(s);
}
}
2027
#include <stdio.h>
#include <string.h>
int main() {
int test;
int num_a, num_e, num_i, num_o, num_u;
scanf("%d", &test);
getchar();
while (test--) {
num_a = num_e = num_i = num_o = num_u = 0;
char s[101];
gets(s);
int len = strlen(s);
for (int i = 0; i < len; i++) {
switch (s[i]) {
case 'a':
num_a++;
break;
case 'e':
num_e++;
break;
case 'i':
num_i++;
break;
case 'o':
num_o++;
break;
case 'u':
num_u++;
break;
}
}
printf("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n", num_a, num_e, num_i, num_o, num_u);
if (test) {
printf("\n");
}
}
}
2028
#include<stdio.h>
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int main() {
int n, a, b, c, i;
while (scanf("%d", &n) != EOF) {
scanf("%d", &a);
for (i = 0; i < n-1; i++) {
scanf("%d", &b);
c = gcd(a, b);
a = a / c * b;
}
printf("%d\n", a);
}
}
2029
#include <stdio.h>
#include <string.h>
int main()
{
int n, flag, start, end;
char s[5000];
scanf("%d", &n);
while(n--) {
scanf("%s", s);
start = 0;
end = strlen(s) - 1;
flag = 1;
while(start < end) {
if(s[end] != s[start]) {
flag = 0;
break;
}
start++;
end--;
}
if(flag)
printf("yes\n");
else
printf("no\n");
}
}
2030
#include <stdio.h>
#include <string.h>
int main ()
{
char ch[1050];
int n,i,sum;
while (scanf("%d",&n)!=EOF)
{
gets(ch);
while (n--)
{
sum=0;
gets(ch);
int l=strlen(ch);
for (i=0; i<l; i++)
if (ch[i]<0)
sum++;
printf ("%d\n",sum/2);
}
}
}
2031
#include<stdio.h>
int main()
{
int m,n;
int ans[50],i,j;
while (scanf("%d%d",&n,&m)!=EOF)
{
j=0;
if(n<0)
{
printf("-");
n= -n;
}
while (n!=0)
{
ans[j++]=n%m;
n= n/m;
}
for(i=j-1;i>=0;i--)
{
if(ans[i]>=10)
printf("%c",ans[i]-10+'A');
else
printf("%d",ans[i]);
}
printf("\n");
}
}
2032
#include<stdio.h>
int main() {
int n;
char d;
int a[31][31] = {0};
while (scanf("%d%c", &n, &d) != EOF) {
a[0][1] = 1;
int i;
for (i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
printf("%d", a[i][j]);
if (j < i)
printf(" ");
}
printf("\n");
}
printf("\n");
}
}
2039
#include<stdio.h>
int main() {
int m;
scanf("%d", &m);
while (m--) {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
if ((a + b > c) && (a + c > b) && (c + b > a))
printf("YES\n");
else
printf("NO\n");
}
}