Skip to content

Commit

Permalink
added findMax
Browse files Browse the repository at this point in the history
  • Loading branch information
junian committed Sep 1, 2013
1 parent 25c0420 commit 82b7130
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Find Maximum Integer in Array/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Find Maximum Number in Array

This code demonstrates how to find maximum integer in an array of integer.
38 changes: 38 additions & 0 deletions Find Maximum Integer in Array/starTheMax.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//Program Array menampilkan 10 bilangan
//dengan memberi * untuk yang terbesar

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

char toUpper(char x){
if (x >= 97 && x <= 122) x = x - 32;
return x;
}

int main(){
int n[9], MAX;
char r;
do{
system("cls");
printf("Program Pencetak 10 Bilangan\n");
printf("============================\n");
printf("* menunjukkan bilangan terbesar\n\n");
//diasumsikan bilangan terbesar yang pertama adalah n[0]
MAX=0;
for(int i=0; i<=9; i++){
printf("Masukkan Bilangan ke-%d: ", i+1);
scanf("%d", &n[i]); fflush(stdin);
if(n[i]>n[MAX]) MAX=i;
}
for(int i=0; i<=9; i++){
printf("\nBilangan ke-%d: %d", i+1, n[i]);
if(i==MAX) printf("*");;
}
printf("\n\nIngin Mengulang [Y/N]? ");
do{
r = toUpper(getch());
}while(r != 'Y' && r != 'N');
}while(r == 'Y');
return 0;
}

0 comments on commit 82b7130

Please sign in to comment.