[关闭]
@yuyuesheng 2019-07-24T22:01:54.000000Z 字数 5509 阅读 632

2016

  1. #include <stdio.h>
  2. #define maxn 1050
  3. int num[maxn],n,temp;
  4. int main()
  5. {
  6. while(scanf("%d",&n)!=EOF){
  7. if(!n)
  8. break;
  9. for (int i = 0; i < n; ++i) {
  10. scanf("%d",&num[i]);
  11. }
  12. int s = 0;
  13. for (int j = 0; j < n; ++j) {
  14. if(num[s]>num[j])
  15. s=j;
  16. }
  17. temp=num[s];
  18. num[s]=num[0];
  19. num[0]=temp;
  20. printf("%d",num[0]);
  21. for (int k = 1; k < n; ++k) {
  22. printf(" %d",num[k]);
  23. }
  24. printf("\n");
  25. }
  26. }

2017

  1. #include <stdio.h>
  2. #include <string.h>
  3. #define maxn 10500
  4. char s[maxn],n;
  5. int main()
  6. {
  7. while(scanf("%d",&n)!=EOF){
  8. for (int j = 0; j < n; ++j) {
  9. scanf("%s",s);
  10. int l = strlen(s),ans=0;
  11. for (int i = 0; i < l; ++i) {
  12. if(s[i]<='9'&&s[i]>='0')
  13. ans++;
  14. }
  15. printf("%d\n",ans);
  16. }
  17. }
  18. }

2018

  1. #include <stdio.h>
  2. #include <string.h>
  3. #define maxn 10500
  4. int ans[maxn],n;
  5. int main()
  6. {
  7. ans[1]=1;
  8. ans[2]=2;
  9. ans[3]=3;
  10. for (int k = 4; k < 60; ++k) {
  11. ans[k]=ans[k-1]+ans[k-3];
  12. }
  13. while(scanf("%d",&n)!=EOF){
  14. if(!n)
  15. break;
  16. printf("%d\n",ans[n]);
  17. }
  18. }

2019

  1. #include <stdio.h>
  2. #include <string.h>
  3. #define maxn 10500
  4. int num[maxn],n,m,ans;
  5. int main()
  6. {
  7. while(scanf("%d%d",&n,&m)!=EOF){
  8. if(!n&&!m)
  9. break;
  10. for (int i = 0; i < n; ++i) {
  11. scanf("%d",&num[i]);
  12. }
  13. if(m<=num[0]||m>=num[n]){
  14. if(m<=num[0])
  15. ans=0;
  16. else
  17. ans=n;
  18. }
  19. for (int j = 1; j < n; ++j) {
  20. if(num[j-1]<=m&&num[j]>=m)
  21. ans=j;
  22. }
  23. if(ans==0){
  24. printf("%d",m);
  25. for (int i = 0; i < n; ++i) {
  26. printf(" %d",num[i]);
  27. }
  28. printf("\n");
  29. }
  30. else{
  31. printf("%d",num[0]);
  32. for (int i = 1; i < n; ++i) {
  33. if(i==ans)
  34. printf(" %d",m);
  35. printf(" %d",num[i]);
  36. }
  37. printf("\n");
  38. }
  39. }
  40. }

2020

  1. #include<stdio.h>
  2. #include<math.h>
  3. int temp, num[1000];
  4. int main() {
  5. int n;
  6. while (scanf("%d", &n) != EOF) {
  7. if(!n)
  8. break;
  9. for (int i = 0; i < n; i++)
  10. scanf("%d", &num[i]);
  11. for (int i = 0; i < n; i++) {
  12. for (int j = i; j < n; j++) {
  13. if (fabs(num[i]) < fabs(num[j])) {
  14. temp = num[i];
  15. num[i] = num[j];
  16. num[j] = temp;
  17. }
  18. }
  19. }
  20. printf("%d",num[0]);
  21. for (int k = 1; k < n; ++k) {
  22. printf(" %d",num[k]);
  23. }
  24. printf("\n");
  25. }
  26. }

2021

  1. #include<stdio.h>
  2. #include<math.h>
  3. int coin[6]={100,50,10,5,2,1},temp;
  4. int solve(int n){
  5. int cnt = 0;
  6. for (int i = 0; i < 6; ++i) {
  7. cnt+=n/coin[i];
  8. n=n%coin[i];
  9. }
  10. return cnt;
  11. }
  12. int main() {
  13. int n;
  14. while (scanf("%d", &n) != EOF) {
  15. if(!n)
  16. break;
  17. int ans = 0;
  18. for (int i = 0; i < n; i++){
  19. scanf("%d", &temp);
  20. ans+=solve(temp);
  21. }
  22. printf("%d\n",ans);
  23. }
  24. }

2022

  1. #include<stdio.h>
  2. #include<math.h>
  3. #include <stdlib.h>
  4. int n,m,women[1000][1000],ansi,ansj,ans;
  5. int main() {
  6. while (scanf("%d%d",&n,&m)!=EOF){
  7. for (int i = 1; i <= n; ++i) {
  8. for (int j = 1; j <= m; ++j) {
  9. scanf("%d",&women[i][j]);
  10. }
  11. }
  12. ansi=ansj=1;
  13. ans=women[1][1];
  14. for (int k = 1; k <= n; ++k) {
  15. for (int i = 1; i <= m; ++i) {
  16. if(abs(women[k][i])>abs(women[ansi][ansj])){
  17. ansi=k;
  18. ansj=i;
  19. ans=women[k][i];
  20. }
  21. }
  22. }
  23. printf("%d %d %d\n",ansi,ansj,ans);
  24. }
  25. }

2023

  1. #include<stdio.h>
  2. #include<math.h>
  3. #include <stdlib.h>
  4. int n,m,grade[1000][1000],ans;
  5. double avest[1000],avesb[1000];
  6. int main() {
  7. while(scanf("%d%d",&n,&m)!=EOF){
  8. double temp = 0;
  9. ans=0;
  10. for (int i = 1; i <= n; ++i) {
  11. temp=0;
  12. for (int j = 1; j <= m; ++j) {
  13. if(i==1)
  14. avesb[j]=0;
  15. scanf("%d",&grade[i][j]);
  16. temp+=grade[i][j];
  17. avesb[j]+=grade[i][j];
  18. }
  19. avest[i]=(double)temp/m;
  20. }
  21. for (int k = 1; k <= m; ++k) {
  22. avesb[k]=(double)avesb[k]/n;
  23. }
  24. for (int l = 1; l <= n; ++l) {
  25. int judge = 0;
  26. for (int i = 1; i <= m; ++i) {
  27. if(grade[l][i]<avesb[i])
  28. judge=1;
  29. }
  30. if(!judge)
  31. ans++;
  32. }
  33. printf("%.2lf",avest[1]);
  34. for (int i1 = 2; i1 <= n; ++i1) {
  35. printf(" %.2lf",avest[i1]);
  36. }
  37. printf("\n");
  38. printf("%.2lf",avesb[1]);
  39. for (int i1 = 2; i1 <= m; ++i1) {
  40. printf(" %.2lf",avesb[i1]);
  41. }
  42. printf("\n");
  43. printf("%d\n",ans);
  44. printf("\n");
  45. }
  46. }

2024

  1. #include<stdio.h>
  2. #include<string.h>
  3. int main() {
  4. int s, len,sum;
  5. char str[100];
  6. scanf("%d", &s);
  7. getchar();
  8. while (s--) {
  9. sum = 0;
  10. gets(str);
  11. len = strlen(str);
  12. if (str[0] >= '0' && str[0] <= '9')
  13. printf("no\n");
  14. else {
  15. for (int i = 0; i <= len - 1; i++)
  16. if (str[i] >= '0' && str[i] <= '9' || str[i] >= 'a' && str[i] <= 'z' ||str[i] >= 'A' && str[i] <= 'Z' || str[i] == '_')
  17. sum++;
  18. if (sum == len)
  19. printf("yes\n");
  20. else
  21. printf("no\n");
  22. }
  23. }
  24. }

2025

  1. #include <stdio.h>
  2. #include <string.h>
  3. char s[105];
  4. int main()
  5. {
  6. char max;
  7. while(scanf("%s", s) != EOF) {
  8. max = s[0];
  9. int l = strlen(s);
  10. for(int i=0; i < l; i++)
  11. if(s[i] > max)
  12. max = s[i];
  13. for(int i=0; i < l; i++) {
  14. printf("%c", s[i]);
  15. if(s[i] == max)
  16. printf("(max)");
  17. }
  18. printf("\n");
  19. }
  20. }

2026

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4. char s[102];
  5. while (gets(s) != NULL) {
  6. if (s[0] != ' ')
  7. s[0] -= 32;
  8. for (int i = 1; i < strlen(s); i++) {
  9. if (s[i] == ' ') {
  10. s[i + 1] = s[i + 1] - 32;
  11. continue;
  12. }
  13. }
  14. puts(s);
  15. }
  16. }

2027

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4. int test;
  5. int num_a, num_e, num_i, num_o, num_u;
  6. scanf("%d", &test);
  7. getchar();
  8. while (test--) {
  9. num_a = num_e = num_i = num_o = num_u = 0;
  10. char s[101];
  11. gets(s);
  12. int len = strlen(s);
  13. for (int i = 0; i < len; i++) {
  14. switch (s[i]) {
  15. case 'a':
  16. num_a++;
  17. break;
  18. case 'e':
  19. num_e++;
  20. break;
  21. case 'i':
  22. num_i++;
  23. break;
  24. case 'o':
  25. num_o++;
  26. break;
  27. case 'u':
  28. num_u++;
  29. break;
  30. }
  31. }
  32. printf("a:%d\ne:%d\ni:%d\no:%d\nu:%d\n", num_a, num_e, num_i, num_o, num_u);
  33. if (test) {
  34. printf("\n");
  35. }
  36. }
  37. }

2028

  1. #include<stdio.h>
  2. int gcd(int a, int b) {
  3. return b == 0 ? a : gcd(b, a % b);
  4. }
  5. int main() {
  6. int n, a, b, c, i;
  7. while (scanf("%d", &n) != EOF) {
  8. scanf("%d", &a);
  9. for (i = 0; i < n-1; i++) {
  10. scanf("%d", &b);
  11. c = gcd(a, b);
  12. a = a / c * b;
  13. }
  14. printf("%d\n", a);
  15. }
  16. }

2029

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5. int n, flag, start, end;
  6. char s[5000];
  7. scanf("%d", &n);
  8. while(n--) {
  9. scanf("%s", s);
  10. start = 0;
  11. end = strlen(s) - 1;
  12. flag = 1;
  13. while(start < end) {
  14. if(s[end] != s[start]) {
  15. flag = 0;
  16. break;
  17. }
  18. start++;
  19. end--;
  20. }
  21. if(flag)
  22. printf("yes\n");
  23. else
  24. printf("no\n");
  25. }
  26. }

2030

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main ()
  4. {
  5. char ch[1050];
  6. int n,i,sum;
  7. while (scanf("%d",&n)!=EOF)
  8. {
  9. gets(ch);
  10. while (n--)
  11. {
  12. sum=0;
  13. gets(ch);
  14. int l=strlen(ch);
  15. for (i=0; i<l; i++)
  16. if (ch[i]<0)
  17. sum++;
  18. printf ("%d\n",sum/2);
  19. }
  20. }
  21. }

2031

  1. #include<stdio.h>
  2. int main()
  3. {
  4. int m,n;
  5. int ans[50],i,j;
  6. while (scanf("%d%d",&n,&m)!=EOF)
  7. {
  8. j=0;
  9. if(n<0)
  10. {
  11. printf("-");
  12. n= -n;
  13. }
  14. while (n!=0)
  15. {
  16. ans[j++]=n%m;
  17. n= n/m;
  18. }
  19. for(i=j-1;i>=0;i--)
  20. {
  21. if(ans[i]>=10)
  22. printf("%c",ans[i]-10+'A');
  23. else
  24. printf("%d",ans[i]);
  25. }
  26. printf("\n");
  27. }
  28. }

2032

  1. #include<stdio.h>
  2. int main() {
  3. int n;
  4. char d;
  5. int a[31][31] = {0};
  6. while (scanf("%d%c", &n, &d) != EOF) {
  7. a[0][1] = 1;
  8. int i;
  9. for (i = 1; i <= n; i++) {
  10. for (int j = 1; j <= i; j++) {
  11. a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
  12. printf("%d", a[i][j]);
  13. if (j < i)
  14. printf(" ");
  15. }
  16. printf("\n");
  17. }
  18. printf("\n");
  19. }
  20. }

2039

  1. #include<stdio.h>
  2. int main() {
  3. int m;
  4. scanf("%d", &m);
  5. while (m--) {
  6. double a, b, c;
  7. scanf("%lf%lf%lf", &a, &b, &c);
  8. if ((a + b > c) && (a + c > b) && (c + b > a))
  9. printf("YES\n");
  10. else
  11. printf("NO\n");
  12. }
  13. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注