2 solutions

  • 1
    @ 2024-3-25 11:32:25

    #include #include

    using namespace std;

    string s; int ans = 0;

    int main(){ getline(cin,s); //读入一整行到s里(包含空格) for (int i=0;i<s.length();i++) if (s[i] != ' ') ans++;

    cout << ans << endl;
    

    }

    • 0
      @ 2024-3-25 11:32:46

      #include #include using namespace std; string s; int ans=0; int main(){ getline(cin,s); for (int i=0;i<s.length();i++) if(s[i]!=' ') ans++; cout<<ans<<endl; }

      • 1

      Information

      ID
      4022
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      # Submissions
      54
      Accepted
      39
      Uploaded By