9 条题解
-
1
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string n; string s; getline(cin,n); getline(cin,s); int n1 = stoi(n); int count = 0; for(int i = 0; i < n1; i++){ if(s[i] != ' '){ count++; } } cout << count << endl; return 0; }
-
0
#include <iostream> #include <vector> #include <limits> #include<string> using namespace std; int main() { int a; string b; cin >> a; cin.ignore(numeric_limits<streamsize>::max(), '\n'); getline(cin, b); b = b.substr(0, a); int c = 0; for (char d : b) { if (d != ' ') { c++; } } cout << c; return 0; } //输入a,b然后直接历遍非空输出结果
-
0
`` #include <iostream> #include<stdio.h> #include <vector> #include <string> using namespace std;
int main() { string str,t; int n=0,m=0; getline(cin, t); getline(cin, str); n = stoi(t); int size = str.length(); for (int i = 0; i < n; i++) { if (str[i] != ' ')m++; } cout << m; return 0; }
-
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int idx = sc.nextInt(); sc.nextLine(); // 读掉换行符防止影响s字符串的读取 String s = sc.nextLine(); sc.close(); String[] st = s.split(" "); int sum = 0; for (int i = 0; i < st.length; i++) { sum += st[i].length(); } System.out.println(sum); } }
- 1
信息
- ID
- 12
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 1505
- 已通过
- 406
- 上传者