10062 - Tell me the frequencies!
Moderator: Board moderators
10062 - Tell me the frequencies!
What should the answer be if the input is a blank line??
thanks
thanks
this is frustating ...
i was comparing input/output of my prog with a prog of a frined of mine
and it was all the same... but my gets a WA and hes get an aceppted
and we dont know whats wrong. Plzz some find the error ...
[c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int c[96];
void display(){
int i, x, n=99999;
while(n!=0){
for(i=0;i<96;i++){
if(n>c && c!=0){
n=c;
x=i;
continue;
}
if(n==c && x<i){
x=i;
continue;
}
}
if(n==0 || n==99999) break;
printf("%d %d\n", (x+32), n);
c[x]=0;
x = -1;
n = 99999;
}
}
void init(){
int i;
for(i=0;i<96;i++)
c=0;
}
int main(){
char linha[1000];
int check=0, i;
while(fgets(linha,1000,stdin)!=NULL){
if(strlen(linha)==1)
continue;
if(check == 1) printf("\n");
init();
for(i=0;i<strlen(linha)-1;i++){
c[(int) linha -32]++;
}
display();
check=1;
}
return 0;
}
[/c]
Thx..
i was comparing input/output of my prog with a prog of a frined of mine
and it was all the same... but my gets a WA and hes get an aceppted
and we dont know whats wrong. Plzz some find the error ...
[c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int c[96];
void display(){
int i, x, n=99999;
while(n!=0){
for(i=0;i<96;i++){
if(n>c && c!=0){
n=c;
x=i;
continue;
}
if(n==c && x<i){
x=i;
continue;
}
}
if(n==0 || n==99999) break;
printf("%d %d\n", (x+32), n);
c[x]=0;
x = -1;
n = 99999;
}
}
void init(){
int i;
for(i=0;i<96;i++)
c=0;
}
int main(){
char linha[1000];
int check=0, i;
while(fgets(linha,1000,stdin)!=NULL){
if(strlen(linha)==1)
continue;
if(check == 1) printf("\n");
init();
for(i=0;i<strlen(linha)-1;i++){
c[(int) linha -32]++;
}
display();
check=1;
}
return 0;
}
[/c]
Thx..
Someone discovered?
Someone discovered what is causing that problem? I have the same problem... with a lot of different algorithms..
10062(wrong answer)
I have wrong answer.Who can help me.
Code: Select all
#include<stdio.h>
#include<iostream.h>
#include<string.h>
main()
{
char a[1000];
int b[100],c=0,i=0,j=0,n=0,k=0,l=0,m=999,p=0,q=0,r=0,s=0,o=0;
for(k=0;k<=1000;k++)
a[k]=0;
for(k=0;k<=100;k++)
b[k]=0;
while(gets(a))
{
n=strlen(a);
for(i=0;i<n;i++)
{
if(a[i]>=32&&a[i]<=128)
{
j=a[i]-31;
b[j]++;
}
}
for(r=0;r<200;r++)
{
if(b[r]!=0)
s++;
}
for(c=0;c<=s;c++)
{
for(k=0;k<100;k++)
{
if(b[k]<=m && b[k]!=0)
m=b[k];
}
for(k=100;k>0;k--)
{
if(m!=999)
{
if(b[k]==m)
{
o=k+31;
cout << o;
cout <<" "<<m<<endl;
b[k]=0;
m=999;
s--;
}
}
}
}
}
}
10062 WA why??
why do my code get a WA i think nothing goes wrong with it???
can any body help me with this.
thanks...
#include <stdio.h>
int main()
{
char input[1001];
int i, temp, ascii[256];
for ( i = 0; i < 1001; i++ ) {
input = 0;
}
for ( i= 0; i < 256; i++ ) {
ascii = 0;
}
while ( gets(input) != NULL) {
for ( i = 0; i < 1001; i++ ) {
temp = input;
ascii[temp]++;
}
if ( input[0] == input[1] ) {
for ( i = 256; i > 1; i-- ) {
if ( ascii != 0 ) {
printf("%d = %d\n", i, ascii );
}
}
}
else {
for ( i = 1; i < 256; i++ ) {
if ( ascii != 0 ) {
printf("%d = %d\n", i, ascii );
}
}
}
for ( i = 0; i < 1001; i++ ) {
input = 0;
}
for ( i= 0; i < 256; i++ ) {
ascii = 0;
}
putchar('\n');
}
return 0;
}[cpp][/cpp][c][/c]
can any body help me with this.
thanks...
#include <stdio.h>
int main()
{
char input[1001];
int i, temp, ascii[256];
for ( i = 0; i < 1001; i++ ) {
input = 0;
}
for ( i= 0; i < 256; i++ ) {
ascii = 0;
}
while ( gets(input) != NULL) {
for ( i = 0; i < 1001; i++ ) {
temp = input;
ascii[temp]++;
}
if ( input[0] == input[1] ) {
for ( i = 256; i > 1; i-- ) {
if ( ascii != 0 ) {
printf("%d = %d\n", i, ascii );
}
}
}
else {
for ( i = 1; i < 256; i++ ) {
if ( ascii != 0 ) {
printf("%d = %d\n", i, ascii );
}
}
}
for ( i = 0; i < 1001; i++ ) {
input = 0;
}
for ( i= 0; i < 256; i++ ) {
ascii = 0;
}
putchar('\n');
}
return 0;
}[cpp][/cpp][c][/c]
Re: 10062 WA why??
output contains an equal sign
& OUPUT:
AAA
256 = 6553144
65 = 3
??
& OUPUT:
AAA
256 = 6553144
65 = 3
??
RE:
Actually, your program has some problems
1. the order
input :ABCDEF
output:
70 1
69 1
68 1
67 1
66 1
65 1
notice that the largest ascii value comes first
2. input:
AAA
256 = 6553144 (<---- why is it printed ?)
65 = 3
even when the input is nothing, your program also prints this line...
1. the order
input :ABCDEF
output:
70 1
69 1
68 1
67 1
66 1
65 1
notice that the largest ascii value comes first
2. input:
AAA
256 = 6553144 (<---- why is it printed ?)
65 = 3
even when the input is nothing, your program also prints this line...