Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
157855 曹奕晗 字符串中最大的数字II C++ Compile Error 0 MS 0 KB 329 2026-08-18 16:12:10

Tests(0/0):


Code:

#include<iostream> using namespace std; int main() { char n; int max=n[0]-'0'; cin>>n; int a=strlen(n); for(int i=1;i<=n;i++) { if(n[i]=='.') { continue; } if(n[i]-'0'>max) { max=a[i]-'0'; } } cout<<max; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:6:16: error: invalid types 'char[int]' for array subscript
     int max=n[0]-'0';
                ^
Main.cc:8:19: error: 'strlen' was not declared in this scope
     int a=strlen(n);
                   ^
Main.cc:11:15: error: invalid types 'char[int]' for array subscript
         if(n[i]=='.')
               ^
Main.cc:15:15: error: invalid types 'char[int]' for array subscript
         if(n[i]-'0'>max)
               ^
Main.cc:17:20: error: invalid types 'int[int]' for array subscript
             max=a[i]-'0';
                    ^