标签:image 输出 ace stream for ret 通过 names scanf
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int input,search;
scanf("%d",&input);
int *score = new int[input];
for(int i=0;i<input;++i)
{
scanf("%d",&score[i]);
}
scanf("%d",&search);
int *search_score = new int[search];
for(int j=0;j<search;++j)
{
scanf("%d",&search_score[j]);
}
int num[100] = {0};
int flag=0;
for(int x=0;x<input;++x)
{
flag = score[x];
num[flag]++;
}
//以下为正确做法,不会出现错误
for(int y=0;y<search;++y)
{
flag = search_score[y];
cout<<num[flag];
if(y!=search-1) cout<<" ";
}
return 0;
}
代码如下:
int temp = search_score[0];
cout<<num[temp];
for(int y=1;y<search;++y)
{
flag = search_score[y];
cout<<" "<<num[flag];
}
标签:image 输出 ace stream for ret 通过 names scanf
原文地址:https://www.cnblogs.com/kayden-su/p/13374154.html