Problem Type : String
#include<stdio.h>
#include<string.h>
int main()
{
char ch[200];
int i,j,cou;
while(gets(ch))
{
int len = strlen(ch);
cou=0;
for(i=0; i<len; i++)
{
if(ch[i]=='!')
{
printf("\n");
}
else if(ch[i]=='0'){
cou+=0;
}
else if(ch[i]=='1')
{
cou+=1;
}
else if(ch[i]=='2')
{
cou+=2;
}else if(ch[i]=='3')
{
cou+=3;
}
else if(ch[i]=='4')
{
cou+=4;
}
else if(ch[i]=='5')
{
cou+=5;
}
else if(ch[i]=='6')
{
cou+=6;
}
else if(ch[i]=='7')
{
cou+=7;
}
else if(ch[i]=='8')
{
cou+=8;
}
else if(ch[i]=='9')
{
cou+=9;
}
else if(ch[i]>=65 && ch[i]<=90|| ch[i]=='*')
{
for(j=0;j<cou;j++)
{
printf("%c",ch[i]);
}
cou=0;
}
else if(ch[i]=='b')
{
for(j=0;j<cou;j++)
{
printf(" ");
}
cou=0;
}
}
printf("\n");
}
}
#include<stdio.h>
#include<string.h>
int main()
{
char ch[200];
int i,j,cou;
while(gets(ch))
{
int len = strlen(ch);
cou=0;
for(i=0; i<len; i++)
{
if(ch[i]=='!')
{
printf("\n");
}
else if(ch[i]=='0'){
cou+=0;
}
else if(ch[i]=='1')
{
cou+=1;
}
else if(ch[i]=='2')
{
cou+=2;
}else if(ch[i]=='3')
{
cou+=3;
}
else if(ch[i]=='4')
{
cou+=4;
}
else if(ch[i]=='5')
{
cou+=5;
}
else if(ch[i]=='6')
{
cou+=6;
}
else if(ch[i]=='7')
{
cou+=7;
}
else if(ch[i]=='8')
{
cou+=8;
}
else if(ch[i]=='9')
{
cou+=9;
}
else if(ch[i]>=65 && ch[i]<=90|| ch[i]=='*')
{
for(j=0;j<cou;j++)
{
printf("%c",ch[i]);
}
cou=0;
}
else if(ch[i]=='b')
{
for(j=0;j<cou;j++)
{
printf(" ");
}
cou=0;
}
}
printf("\n");
}
}
No comments:
Post a Comment