6 条题解

• @ 2021-03-31 21:25:15
``````#include<iostream>
#include<cstring>
using namespace std;
namespace ee
{
int tongji(char *a)
{
int cnt=0;
for(int i=0;i<strlen(a);i++)
if(a[i]>='a'&&a[i]<='z')
cnt++;
return cnt;
}
int tongji1(char *a)
{
int cnt=0;
for(int i=0;i<strlen(a);i++)
if(a[i]>='A'&&a[i]<='Z')
cnt++;
return cnt;
}
}
const int N=10000;
int main()
{
char a[N],b[N];
gets(a);
gets(b);
int cnta=ee::tongji(a);
int cntb=ee::tongji(b);
int cnta1=ee::tongji1(a);
int cntb1=ee::tongji1(b);
cout<<cnta1-cnta<<" "<<cntb1-cntb;
return 0;
}
``````
• @ 2019-10-21 10:56:09
``````#include<iostream>
#include<string>
using namespace std;

int get_big(string s)
{
int len=s.length();
int flag=0;
for(int i=0;i<len;i++)
{
if(s[i]>='A' && s[i]<='Z')
flag++;
}
return flag;
}

int get_small(string s)
{
int len=s.length();
int flag=0;
for(int i=0;i<len;i++)
{
if(s[i]>='a' && s[i]<='z')
flag++;
}
return flag;
}

int main()
{
string s1,s2;
getline(cin,s1);
getline(cin,s2);
//cout<<get_big(s)<<endl;
cout<<get_big(s1)-get_small(s1)<<" ";
cout<<get_big(s2)-get_small(s2)<<endl;

system("pause");
return 0;
}

``````
• @ 2021-07-11 12:52:46

#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{
int bcnt1=0,bcnt2=0;
int scnt1=0,scnt2=0;
getline(cin,s1);
getline(cin,s2);
for(int i=0;i<s1.size();i++)
{
if(s1[i]>='a' && s1[i]<='z')
scnt1++;
if(s1[i]>='A' && s1[i]<='Z')
bcnt1++;
}
for(int i=0;i<s2.size();i++)
{
if(s2[i]>='a' && s2[i]<='z')
scnt2++;
if(s2[i]>='A' && s2[i]<='Z')
bcnt2++;
}
cout<<bcnt1-scnt1<<" "<<bcnt2-scnt2<<endl;
return 0;
}

• @ 2021-01-27 21:37:32

死算的办法，不推荐。
#include<bits/stdc++.h>

using namespace std;

int main()
{
int res=0,sum=0;
int x1=0,x2=0;
char a[10010],b[10010];
fgets(a,10000,stdin);
fgets(b,10000,stdin);

int cnt=0;
for(int i=0;i<10000;i++)
if(a[i])
cnt++;

for(int i=0;i<cnt;i++)
if(isupper(a[i]))
res++;

for(int i=0;i<cnt;i++)
if(islower(a[i]))
sum++;

int k=0;
for(int j=0;j<10000;j++)
{
if(b[j])
k++;
}

for(int j=0;j<k;j++)
{
if(isupper(b[j]))
x1++;
}

for(int j=0;j<k;j++)
{
if(islower(b[j]))
x2++;
}

cout<<(res-sum)<<' '<<(x1-x2)<<endl;

return 0;
}

• @ 2019-11-19 14:58:19

#include <stdio.h>
#include <string.h>
int Diff(char s[]);
int main()
{
char s1[10000],s2[10000];
gets(s1);
gets(s2);
printf("%d %d",Diff(s1),Diff(s2));
return 0;
}

int Diff(char s[])
{
int i=0,j=0,k=0,x,n;
for(i=0,n=strlen(s);i<n;i++)
{
if((s[i]>='a')&&(s[i]<='z'))
j++;
if((s[i]>='A')&&(s[i]<='Z'))
k++;

}
return k-j;
}

• @ 2021-01-29 20:06:30
``````#include<iostream>
#include<string>
using namespace std;
int Diff(string a)
{
int X=0,D=0;
int orz=a.size();
for(int i=0;i<orz;i++)
{
if(a[i]>='A'&&a[i]<='Z')
D++;
if(a[i]>='a'&&a[i]<='z')
X++;
}
return D-X;
}
int main()
{
string a,b;
getline(cin,a);
getline(cin,b);
cout<<Diff(a)<<" "<<Diff(b);

return 0;
}
``````
• 1

5

(无)

1248

462

37%

5