讨论 / 求解...
博丽灵梦 2013-11-06 20:43:15
点我顶贴 收藏 删除
为什么会莫名的无输出T T

#include<iostream>

#include<cstdio>

using namespace std;

long a[500005],m,mo,n,i;

long long t[15];

int main()

{

cin>>m>>n;

for(i=0;i<=n-m;i++)

a[i+1]=i+m;

for(i=1;i<=n-m+1;i++)

{

while(a[i]!=0)

{

mo=a[i];

a[i]/=10;

t[mo]++;

}

}

for(i=0;i<=9;i++)

cout<<t[i]<<' ';

return 0;

}

#1 博丽灵梦@2013-11-06 20:49:05
回复 删除
PS:题目为PID11
#2 Cgb@2022-05-26 18:55:20
回复 删除
#include<iostream>

#include<algorithm>

using namespace std;

int a[500001];

int main()

{

int m,n;

int b;

int c0=0,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0,c8=0,c9=0;

cin>>m>>n;

for(int i=0;i<n-m+1;i++)

{

a[i]=m+i;

}

for(int i=0;i<n-m+1;i++)

{

while(a[i]!=0)

{

b=a[i]%10;

if(b==0)

{

c0++;

}

if(b==1)

{

c1++;

}

if(b==2)

{

c2++;

}

if(b==3)

{

c3++;

}

if(b==4)

{

c4++;

}

if(b==5)

{

c5++;

}

if(b==6)

{

c6++;

}

if(b==7)

{

c7++;

}

if(b==8)

{

c8++;

}

if(b==9)

{

c9++;

}

a[i]=a[i]/10;

}

}

cout<<c0<<" "<<c1<<" "<<c2<<" "<<c3<<" ";

cout<<c4<<" "<<c5<<" "<<c6<<" "<<c7<<" ";

cout<<c8<<" "<<c9<<" "<<endl;

return 0;

}

#3 suntra@2022-07-18 11:17:09
回复 删除
``` c++

#include <algorithm>

#include <iostream>

using namespace std;

int a[500001];

int main()

{

int m, n;

int b;

int c0 = 0, c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0;

cin >> m >> n;

for (int i = 0; i < n - m + 1; i++)

{

a[i] = m + i;

}

for (int i = 0; i < n - m + 1; i++)

{

while (a[i] != 0)

{

b = a[i] % 10;

if (b == 0)

{

c0++;

}

if (b == 1)

{

c1++;

}

if (b == 2)

{

c2++;

}

if (b == 3)

{

c3++;

}

if (b == 4)

{

c4++;

}

if (b == 5)

{

c5++;

}

if (b == 6)

{

c6++;

}

if (b == 7)

{

c7++;

}

if (b == 8)

{

c8++;

}

if (b == 9)

{

c9++;

}

a[i] = a[i] / 10;

}

}

cout << c0 << " " << c1 << " " << c2 << " " << c3 << " ";

cout << c4 << " " << c5 << " " << c6 << " " << c7 << " ";

cout << c8 << " " << c9 << " " << endl;

return 0;

}

```

查看更多回复
提交回复