-
Notifications
You must be signed in to change notification settings - Fork 302
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 #2 from SudhanshuMishra8826/master
added linear search implementation in c.
- Loading branch information
Showing
2 changed files
with
35 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,11 @@ | ||
def bubbleSort(arr): | ||
n = len(arr) | ||
for i in range(n): | ||
for j in range(0, n-i-1): | ||
if arr[j] > arr[j+1] : | ||
arr[j], arr[j+1] = arr[j+1], arr[j] | ||
arr = [64, 34, 25, 12, 22, 11, 90] | ||
bubbleSort(arr) | ||
print ("Sorted array is:") | ||
for i in range(len(arr)): | ||
print ("%d" %arr[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,24 @@ | ||
#include <stdio.h> | ||
void main() | ||
{ | ||
int a[10], i, item,n,flag=0; | ||
printf("Enter number of elements : "); | ||
scanf("%d",&n); | ||
printf("\nEnter elements of an array:\n"); | ||
for (i=0; i<n; i++) | ||
{printf("Element : "); | ||
scanf("%d", &a[i]);} | ||
printf("\nEnter item to search: "); | ||
scanf("%d", &item); | ||
for (i=0; i<n; i++) | ||
{ | ||
if (item == a[i]) | ||
{ flag=1; | ||
printf("\nItem found at location %d", i+1); | ||
break; | ||
} | ||
} | ||
if (flag==0) | ||
printf("\nItem does not exist."); | ||
getch(); | ||
} |
This comment was marked as outdated.
Sorry, something went wrong.
7c4d0f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment on 7c4d0f0.
There are 22 results for the section all.pyjava. They have been shortened and will not be shown inline because they are more than 10.
Until GitMate provides an online UI to show a better overview, you can run coala locally for more details.
This comment was marked as outdated.
Sorry, something went wrong.