forked from vglug/ProgrammingLogic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request vglug#32 from dilip0207/main
reverse_all_the_words_in_a_sentence
- Loading branch information
Showing
7 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include<stdio.h> | ||
void main() | ||
{ | ||
int max,i,n,temp,rem,sum=0; | ||
scanf("%d",&n); | ||
int a[n]; | ||
for(i=0;i<n;i++) | ||
{ | ||
scanf("%d",&a[i]); | ||
} | ||
max=a[0]; | ||
i=1; | ||
while(i<n) | ||
{ | ||
if(max<a[i]) | ||
max=a[i]; | ||
|
||
i++; | ||
} | ||
float preci; | ||
temp=max; | ||
while(temp) | ||
{ | ||
rem=temp%10; | ||
sum=sum+rem; | ||
temp=temp/10; | ||
} | ||
i=0; | ||
while(i<n) | ||
{ | ||
preci=(float)a[i]/sum; | ||
printf("%.2f ",preci); | ||
i++; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include<stdio.h> | ||
void main() | ||
{ | ||
int j,i,n,a=-1,b=1,c=0; | ||
int d[20]; | ||
scanf("%d",&n); | ||
i=0; | ||
while(i<n) | ||
{ | ||
c=a+b; | ||
d[i]=c; | ||
a=b; | ||
b=c; | ||
i++; | ||
} | ||
for(j=i-1;j>=0;j--) | ||
{ | ||
printf("%d ",d[j]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
int findlength(char s[]) | ||
{ | ||
int i,count=0; | ||
for(i=0;s[i]!='\0';i++) | ||
{ | ||
count++; | ||
} | ||
return count; | ||
} | ||
void main() | ||
{ | ||
int i,n,j; | ||
char s[30]; | ||
gets(s); | ||
n=findlength(s); | ||
for(i=0;i<n;i++) | ||
{ | ||
if(s[i]!=' ') | ||
{ | ||
printf("%c",s[i]); | ||
} | ||
else | ||
break; | ||
} | ||
printf(" "); | ||
i++; | ||
for(;i<n;i++) | ||
{ | ||
if(s[0]==s[i] && s[i-1]==' ') | ||
{ | ||
for(j=i;j<n;j++) | ||
{ | ||
if(s[j]!=' ') | ||
{ | ||
printf("%c",s[j]); | ||
} | ||
else | ||
break; | ||
} | ||
printf(" "); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
void main() | ||
{ | ||
int i,n,j,k; | ||
char s[30]; | ||
gets(s); | ||
n=strlen(s); | ||
int a[20]; | ||
a[0]=-1; | ||
j=1; | ||
for(i=0;i<n;i++) | ||
{ | ||
if(s[i]==' ') | ||
{ | ||
a[j]=i; | ||
j++; | ||
} | ||
} | ||
a[j]=n; | ||
j++; | ||
for(k=0;k<j;k++) | ||
{ | ||
for(i=a[k+1]-1;i>a[k];i--) | ||
{ | ||
printf("%c",s[i]); | ||
} | ||
printf(" "); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include<stdio.h> | ||
int isrev(int n) | ||
{ | ||
int temp,rev=0,rem; | ||
temp=n; | ||
while(temp) | ||
{ | ||
rem=temp%10; | ||
rev=rev*10+rem; | ||
temp=temp/10; | ||
} | ||
return rev; | ||
} | ||
void main() | ||
{ | ||
int n,i,sum1,count=0; | ||
printf("enter the number"); | ||
scanf("%d",&n); | ||
for(;;) | ||
{ | ||
sum1=isrev(n)+n; | ||
if(sum1==isrev(sum1)) | ||
{ | ||
printf(" %d is the palindrome number ",sum1); | ||
break; | ||
} | ||
n=sum1; | ||
count++; | ||
} | ||
printf("\n %d times iterated till palindrome obtain",count); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
struct except | ||
{ | ||
char a[30]; | ||
}; | ||
int findlength(char s[]) | ||
{ | ||
int i,count=0; | ||
for(i=0;s[i]!='\0';i++) | ||
{ | ||
count++; | ||
} | ||
return count; | ||
} | ||
void main() | ||
{ | ||
int i,n,x,flag=0; | ||
scanf("%d%d",&n,&x); | ||
struct except b[n]; | ||
for(i=0;i<n;i++) | ||
{ | ||
scanf("%s",b[i].a); | ||
} | ||
for(i=0;i<n;i++) | ||
{ | ||
if(x!=(findlength(b[i].a))) | ||
{ | ||
printf("%s \n",b[i].a); | ||
flag=1; | ||
} | ||
} | ||
if(flag==0) | ||
printf("-1"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
int findlength(char s[]) | ||
{ | ||
int i,count=0; | ||
for(i=0;s[i]!='\0';i++) | ||
{ | ||
count++; | ||
} | ||
return count; | ||
} | ||
void main() | ||
{ | ||
int i,n,j; | ||
char s[30]; | ||
gets(s); | ||
n=findlength(s); | ||
char vowel[10]; | ||
j=0; | ||
for(i=0;i<n;i++) | ||
{ | ||
if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u') | ||
{ | ||
vowel[j]=s[i]; | ||
j++; | ||
} | ||
} | ||
vowel[j]='\0'; | ||
for(i=0;i<j/2;i++) | ||
{ | ||
if(vowel[i]!=vowel[j-1-i]) | ||
break; | ||
} | ||
if(i==j/2) | ||
{ | ||
printf("yes"); | ||
} | ||
} |