首页 > [NOIP2018]标题统计
头像 yxiu1
发表于 2022-08-30 14:30:43
emm看了一圈大伙的答案,好像都着重在scanf不能吸收空格或换行的特点上了,但是为什么没人利用一下呢? 个人认为这道题偷跑的方法,应该是C语言代码中最简单的了,代码如下: #include <stdio.h> #include <string.h> int m 展开全文
头像 savage
发表于 2019-09-07 15:53:31
算法知识点: 字符串处理 复杂度: 解题思路: 当用cin读入char类型时,会自动忽略空白字符,包括空格、制表符、回车等。 因此可以直接利用这个特性,统计总共读入多少个非空白字符即可。 C++ 代码: #include <iostream> 展开全文
头像 寒山客L
发表于 2022-02-27 14:06:01
C语言: 分为了几种情况分别计数 #include<stdio.h> #include<string.h> int main(){ int sum=0,i; char s[100]; gets(s);//gets才能吸收空格 for(i=0;i 展开全文
头像 老6
发表于 2022-05-11 16:05:24
#include <stdio.h> int main(){     char a[100];     int sum=0;     gets(a);     for(int i=0;a[i]!=0;i++) 展开全文
头像 尙尢
发表于 2021-12-12 20:42:19
String str=sc.nextLine(); 以换行符为结束符。 String str=sc.next(); 以空格、换行符为结束符。 import java.util.*; public class Main{ public static void main(String arg[ 展开全文
头像 Zerone·
发表于 2022-05-26 17:08:22
">#include<string.h> int main() { int n, m = 0; char s[100] = {0}; gets(s); n = strlen(s); for (int i = 0; i < n; i++) { 展开全文
头像 小鸡摸
发表于 2024-11-17 15:26:23
import java.util.Scanner; import java.io.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args)throw 展开全文
头像 臭猪脱脱
发表于 2022-07-27 14:01:30
#include<stdio.h> #include<string.h> int main(){     char c[100];     int sum=0,i;     gets(c);     展开全文
头像 怕黑的牛油为你答疑解惑
发表于 2024-10-11 18:39:06
#include <iostream> #include <string> using namespace std; int countNonWhitespaceCharacters(const string& title) { int count = 0 展开全文
头像 小帅强
发表于 2024-01-17 15:43:53
#include <stdio.h> int main() { int cot=0; char c; while ((c=getchar()) != EOF) { if(c!=' '&&c!='\n') 展开全文

等你来战

查看全部