Day6.(每日一题)A. Chat Server‘s Outgoing Traffic(C语言)

Day6.(每日一题)A. Chat Server‘s Outgoing Traffic(C语言)

Day6.(每日一题)A. Chat Server‘s Outgoing Traffic(C语言) 

Day6.(每日一题)A. Chat Server‘s Outgoing Traffic(C语言) 

 

#include <stdio.h>
#include <string.h>
int main()
{
	char s[101];
	int cnt=0,sum=0;
	while(gets(s))
	{
		if(s[0]=='+')
		cnt++;
		else if(s[0]=='-')
		cnt--;
		else
		{	
			int i=0;
			while(s[i]!=':')
			i++;
			sum+=(strlen(s)-i-1)*cnt;
		}
		memset(s,0,sizeof(s));
	}
	printf("%d\n",sum);
	return 0;
}

上一篇:Java寒假学习Day6:面向对象(1)


下一篇:七天玩转Redis | Day6、SpringBoot集成Redis