题解
2024-03-17 11:07:20
发布于:陕西
68阅读
0回复
0点赞
#include <stdio.h>
#include <iostream>
#include <ctype.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);//另外提醒大家,加上这个就不要用scanf和printf了
char s1[101*101*101]={};
int i=1,j,k,s=0,t=0;//s计算流量,t计算人数
while(gets(s1))//不断读入数据,直到读入回车+Ctrl+Z+回车
{
if(s1[0]=='+')//如果前缀为+
{
t++;
}
else if(s1[0]=='-')//如果前缀为-
{
t--;
}
else//如果是消息
{
j=0;
while(s1[j]-':')//向右扫描直到冒号
{
j++;//指向
}
s=s+(strlen(s1+1)-j)*t;//累计流量
}
}
cout<<s<<endl;//输出流量
return 0;
}
全部评论 1
锣鼓的题解好抄吗
2024-07-28 来自 广东
0包好的
2024-12-14 来自 浙江
0
有帮助,赞一个