Akash JAVA CODE —————————————————————————————————————————————- public static void main (String[] args) throws java.lang.Exception { try{ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); System.out.println(s.replaceAll(” “,” “)); }catch(Exception e){} } ——————————————————————————————————————————————- Log in to Reply
HEMAPRAKASH #include #include int main() { char str[]=”If you know, you know”, sentence[100][100]; int n=strlen(str); printf(“%d\n”,n); int i,j=0,count=0,dummy=0; for(i=0;i<n;i++) { if(str[i]!=' '&& str[i]!='\0') { sentence[count][j]=str[i]; j++; dummy=0; } else { if(dummy<=0) { sentence[count][j]=' '; count++; j=0; dummy++; } else{ j=0; } } } for(i=0;i<=count;i++) { printf("%s",sentence[i]); } return 0; } Log in to Reply
Gourav strr=’I am Gourav Raghuwanshi’ strr=strr.split() print(strr) print(‘ ‘.join(strr)) Log in to Reply
JAVA CODE
—————————————————————————————————————————————-
public static void main (String[] args) throws java.lang.Exception
{
try{
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
System.out.println(s.replaceAll(” “,” “));
}catch(Exception e){}
}
——————————————————————————————————————————————-
#include
#include
int main()
{
char str[]=”If you know, you know”, sentence[100][100];
int n=strlen(str);
printf(“%d\n”,n);
int i,j=0,count=0,dummy=0;
for(i=0;i<n;i++)
{
if(str[i]!=' '&& str[i]!='\0')
{
sentence[count][j]=str[i];
j++;
dummy=0;
}
else
{
if(dummy<=0)
{
sentence[count][j]=' ';
count++;
j=0;
dummy++;
}
else{
j=0;
}
}
}
for(i=0;i<=count;i++)
{
printf("%s",sentence[i]);
}
return 0;
}
strr=’I am Gourav Raghuwanshi’
strr=strr.split()
print(strr)
print(‘ ‘.join(strr))
n=input().split()
for i in n:
if i !=” “:
print(i+” “,end=””)
n = input().split()
print(*n,sep = ” “)