Tampilkan postingan dengan label visual. Tampilkan semua postingan
Tampilkan postingan dengan label visual. Tampilkan semua postingan
berikut ini source code untuk mencari nilai modus (nilai data yang paling sering muncul) dari n buah data, silahkan dicermati : 
/**-----------------------------.
Program Modus dengan bahasa C   |
Diprogram oleh : pemrogram      |
------------------------------**/

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

#define _MY_DEBUG
#if defined(_MY_DEBUG)
    #define TRACE_LINE printf("\n1. Line : %d\n2. File : %s\n",__LINE__,__FILE__);
#else
    #define TRACE_LINE
#endif
#define MAX 20
#define DELAY 10000000
#define INPUT 'i'
#define OUTPUT 'o'
#define TRUE 1
#define FALSE 0

typedef struct {
    int number, sigma;
} Data;

typedef struct {
    int count;
    Data* data;
} List;

int InList(List, int),
    Modus(int*, int),
        ChoosePivot(int, int);
            void UpdateList(List*, int),
                AppendtoList(List*, int),
                    InputOutput(int*, int, const char),
                QuickSort(int*, int, int),
            // SelectionSort(int*, int),
        Swap(int*, int*),
    Delay(void),
FreeBuffer(int*);

int main(int argc, char *argv[]) {
    system("COLOR 5");
    int *buffer, n;
    printf("Masukkan banyak data : ");
    scanf("%d",&n);
    fflush(stdin);
    if((n > FALSE) && (n <= MAX)) {
        buffer = (int*)calloc(n,sizeof(int));
        InputOutput(buffer,n,INPUT);
        printf("\n1. Data yang anda masukkan : ");
        InputOutput(buffer,n,OUTPUT);
        QuickSort(buffer,FALSE,(n-TRUE)); // FALSE = 0;
        // SelectionSort(buffer,n);
        printf("\n2. Data setelah disorting : ");
        InputOutput(buffer,n,OUTPUT);
        printf("\n3. Modus : %d\n",Modus(buffer,n));
    }
    FreeBuffer(buffer);
    getch();
    return(EXIT_SUCCESS);
}


#include
#include
#include

#define _MY_DEBUG
#if defined(_MY_DEBUG)
    #define TRACE_LINE printf("\n1. Line : %d\n2. File : %s\n",__LINE__,__FILE__);
#else
    #define TRACE_LINE
#endif
#define MAX 30

int SequentSearch(int*, int, int, int*, int*);
void InputData(int*, int), FreeBuffer(int*, int*);

int main(int argc, char *argv[]) {
    system("COLOR 3");
    int max;
    puts("Sequential Search");
    printf("Input a number : ");
    scanf("%d",&max);
    fflush(stdin);
    if((max > 0) && (max <= MAX)) {
        int key, sum = 0,
        *buffer = (int*)calloc(max,sizeof(int)),
        *pos    = (int*)calloc(max,sizeof(int));
        InputData(buffer,max);
        printf("\nInput a Key : ");
        scanf("%d",&key);
        fflush(stdin);
        puts("\nResult :");
        if(SequentSearch(buffer,max,key,pos,&sum)) {
            int i = 0;
            printf("1. Sum of Data     : %d\n",sum);
            printf("2. Position        : ");
            while((pos[i]) && (i < sum)) {
                printf("%d ",pos[i++]); 



Introduction:

Welcome to the C# Station Tutorial.  This is a set of lessons suited for beginning to intermediate programmers or anyone who would like to gain familiarity with the C# programming language.  These lessons will help you get a quick head-start with C# programming. 
To get started, you will need a compiler and an editor. There are several options for obtaining a compiler to write C# programs.  A free option is to download the .NET Frameworks SDK and use Notepad.  Of course there are many editor and IDE options available, so see the Tools section to select the option that's right for you. Most of the examples in these tutorials run as console programs.  Microsoft Visual Studio .NET is also available in multiple versions as well as a free download for Visual Studio Express tools, including Visual C# Express.
This tutorial is a work in progress.  It's quality is a product of volunteer reviews and valuable feedback received from many readers.  Please visit periodically for the latest updates and new lessons.
Once you've completed this tutorial, you may be interested in additional resources to continue learning C#.  There are additional Articles on this site and a Links section will guide you to many high-quality web sites that specialize in certain .NET technologies.
I hope you enjoy the tutorial, and best of luck! Joe

References:


 

My Pictures