提出 #76597089


ソースコード 拡げる

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
  char c, s[120];
  int ct=0;
  scanf("%s", s);
  for(int i=0; i<strlen(s); i++)
  {
    if('a'<=s[i] && s[i]<='z') ct++;
    else ct--;
  }
  if(ct>0) for(int i=0; i<strlen(s); i++) if(isupper(s[i])) s[i]=tolower(s[i]);
  if(ct<0) for(int i=0; i<strlen(s); i++) if(islower(s[i])) s[i]=toupper(s[i]);
  printf("%s\n", s);
  return 0;
}

提出情報

提出日時
問題 C - Uppercase and Lowercase
ユーザ kodukikohaku
言語 C23 (GCC 14.2.0)
得点 200
コード長 429 Byte
結果 AC
実行時間 0 ms
メモリ 1680 KiB

コンパイルエラー

Main.c: In function ‘main’:
Main.c:10:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
   10 |   for(int i=0; i<strlen(s); i++)
      |                 ^
Main.c:15:26: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
   15 |   if(ct>0) for(int i=0; i<strlen(s); i++) if(isupper(s[i])) s[i]=tolower(s[i]);
      |                          ^
Main.c:16:26: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
   16 |   if(ct<0) for(int i=0; i<strlen(s); i++) if(islower(s[i])) s[i]=toupper(s[i]);
      |                          ^
Main.c:7:8: warning: unused variable ‘c’ [-Wunused-variable]
    7 |   char c, s[120];
      |        ^
Main.c:9:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%s", s);
      |   ^~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 13
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 0 ms 1576 KiB
00_sample_01.txt AC 0 ms 1652 KiB
00_sample_02.txt AC 0 ms 1652 KiB
01_random_00.txt AC 0 ms 1576 KiB
01_random_01.txt AC 0 ms 1656 KiB
01_random_02.txt AC 0 ms 1576 KiB
01_random_03.txt AC 0 ms 1680 KiB
01_random_04.txt AC 0 ms 1588 KiB
01_random_05.txt AC 0 ms 1608 KiB
01_random_06.txt AC 0 ms 1588 KiB
01_random_07.txt AC 0 ms 1616 KiB
01_random_08.txt AC 0 ms 1652 KiB
01_random_09.txt AC 0 ms 1608 KiB