mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
commit
2efe4a29e4
35
QUSTOJ/1516.cpp
Normal file
35
QUSTOJ/1516.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
int cnt[1005];
|
||||
int main()
|
||||
{
|
||||
int n,tmp;
|
||||
while(scanf("%d",&n)==1&&n!=0)
|
||||
{
|
||||
memset(cnt,0,sizeof(int)*1005);
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
scanf("%d",&tmp);
|
||||
++cnt[tmp];
|
||||
}
|
||||
int c=0;
|
||||
ostringstream ostr;
|
||||
for(int i=0;i<1005;i++)
|
||||
{
|
||||
if(cnt[i])
|
||||
{
|
||||
++c;
|
||||
ostr<<i<<" ";
|
||||
}
|
||||
}
|
||||
printf("%d\n",c);
|
||||
string ans=ostr.str();
|
||||
ans.replace(ans.begin()+ans.size()-1,ans.end(),"\0");
|
||||
printf("%s\n\n",ans.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
19
QUSTOJ/1520.cpp
Normal file
19
QUSTOJ/1520.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <cstdio>
|
||||
int cnt[26];
|
||||
|
||||
int main()
|
||||
{
|
||||
char c;
|
||||
while((c=fgetc(stdin))!='#')
|
||||
{
|
||||
if(c>='a'&&c<='z')
|
||||
{
|
||||
++cnt[c-'a'];
|
||||
}
|
||||
}
|
||||
for(int i=0;i<26;i++)
|
||||
{
|
||||
printf("%c %d\n",i+'a',cnt[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user