why tle????pls help me
Posted: Tue Jan 06, 2009 11:04 am
got AC
got AC
Code: Select all
removed
Code: Select all
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
int n,count=0,c,t_c,i,ca=0;
bool print=0;
char st[31];
scanf("%d%*c",&n);
scanf("%*c");
while(1)
{
printf("Case #%d:\n",++ca);
while(1)
{
gets(st);
if(st[0]=='\0'){count++;break;}
c=0;t_c=0;print=0;
for(i=0;st[i];i++)
{
if(isspace(st[i]))
{
if(print){c++;print=0;}
t_c=0;
}
else
{
if(t_c==c){printf("%c",st[i]);print=1;}
t_c++;
}
}
puts("");
}
if(count==n)break;
puts("");
}
return 0;
}
Code: Select all
#include<stdio.h>
#include<string.h>
int main()
{
int i,j,k,l,m,cas,t,tag,flag,len;
char a[100][2000],bfr,b[100][500];
scanf("%d",&t);
printf("\n");
scanf("%c",&bfr);
for(cas=1;cas<=t;cas++)
{
for(i=0;;i++)
{
gets(a[i]);
if(a[i][0]=='\0')
break;
}
printf("Case #%d:\n",cas);
for(j=0;j<i;j++)
{
l=0;
tag=1;
flag=1;
len=strlen(a[j]);
for(k=0;k<len;k++)
{
if(tag&&a[j][k]!=' ')
for(m=k+1;m<=k+l;m++)
if(a[j][m]==' ')
{
flag=0;
break;
}
if((m==k+l+1)&&flag&&m<len)
{
b[j][l]=a[j][k+l];
tag=0;
flag=0;
l++;
}
if(a[j][k]==' ')
{
tag=1;
flag=1;
}
}
b[j][l]='\0';
puts(b[j]);
}
if(cas<t)
printf("\n");
}
return 0;
}
Code: Select all
scan test case
enter
enter
scan input and print output ( input is terminated when input is only a new line )
scan input and print output ( input is terminated when input is only a new line )
.......
.......
Code: Select all
2
Hey good lawyer
as I previously previewed
yam does a soup(and 4 space)
Code: Select all
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <sstream>
using namespace std;
int counter;
void fn(string s)
{
int l=s.size();
if(l>=counter+1)
{
cout<<s[counter];
counter++;
}
}
int main()
{
string s,smain;
char ch;
int t;
cin>>t;
getchar();
for(int i=1; i<=t; i++)
{
vector<string>ss;
scanf("\n");
scanf("\n");
while(getline(cin,smain))
{
if(smain=="")
{
break;
}
ss.push_back(smain);
}
cout<<"Case #"<<i<<":"<<endl;
for(int j=0; j<ss.size(); j++)
{
counter=0;
s=ss[j];
vector<string>stor;
istringstream iss(s);
do
{
string sub;
iss >> sub;
stor.push_back(sub);
}
while (iss);
for(int k=0; k<stor.size(); k++)
{
fn(stor[k]);
}
cout<<endl;
}
cout<<endl;
}
return 0;
}
Thank you. AC
Code: Select all
#include<stdio.h>
#include<string.h>
int main()
{
int i=1,j,n,words,test_case,length,letters,characters;
char text[110][40];
FILE *fp,*op;
//fp=fopen("Input.txt","r");
//fscanf(fp,"%d",&test_case);
scanf("%d",&test_case);
while(i<=test_case)
{
j=0;
printf("Case #%d:\n",i);
while(gets(text[j]))
{
length=strlen(text[j]);
if(length==0 && j>1)
break;
letters=words=1;
characters=0;
while(text[j][characters]!='\0')
{
if(text[j][characters]!=' ')//checking for words
{
if(letters==1)
words++;
letters++;//counting letters in a word
if(letters==words)
{
printf("%c",text[j][characters]);
}
}
else
{
if(letters<words && letters>1)
words--;
letters=1;
}
characters++;
}
j++;
printf("\n");
}
//fclose(fp);
i++;
}
return 0;
}