DC [21/05/2021]
C Program
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{int arr[1001];
char str[10001],ch;
int len=0,flag=0;
while(scanf("%[^\n]\n",&str)==1)
{
char *token=strtok(str," ");
int cnt=0;
while(token!=NULL)
{
arr[len]=atoi(token);len++;
cnt++;
token=strtok(NULL," ");
}
if(cnt>1)flag=1;
}
if(flag==1)
{
ch='\n';
}
else{
ch=' ';
}
for(int i=len-1;i>=0;i--)
{
printf("%d%c",arr[i],ch);
}
}
Comments
Post a Comment