PDA

View Full Version : bahasa C


abas_19
13-03-2007, 10:16 AM
dear all,

tanya dong apa fungsi matematika utk pembulatan ke atas atau ke bawah dalam bahasa C.

terima kasih.

salam,
Robby

nospacebar
13-03-2007, 10:18 AM
floor sama ceil yah?


Baru dicek, bener, floor() dan floorl() u/ pembulatan ke bawah, ceil() dan ceill() u/ pembulatan ke atas.
Yang ada l-nya itu u/ long.

ruboW
13-03-2007, 11:21 AM
dan jgn lupa round.. tapi dia ada hukum sendiri.. kl ngak salah masalah 0,5.. kl genap.. ke atas, ganjil kebawah

cmiiw

abas_19
14-03-2007, 03:16 PM
thanks yah
maklum lg dapat tugas kuliah utk fungsi matematika di bahasa C

salam,
Robby

anna_ht
14-03-2007, 07:38 PM
hehe, masalah yg robby dah terselesaikan,..
aq mo tanya ni soal C,. ad yg bs ubah program dlm C ini ke bhs Pascal ato psedu code???
(o ya, aq jg lg crt struktur penyimpanan ekstensi PCX, bagi yg tau, boleh bagi2 dunk ::oops:: )

/****************************************************************************\
** Title: PCXWRITE.C **
** Purpose: Write PCX header information to a file. **
** Version: 1.0 **
** Date: May 1991 **
** Author: James D. Murray, Anaheim, CA USA **
** C Compilers: Borland C++ v2.0, Microsoft C v6.00a **
** **
** Write the information contained within a PCXHEADER structure to a file. **
** **
** This module contains the following functions: **
** **
** WritePcxHeader - Write a PCX header to a file stream **
** **
** Copyright (C) 1991 by Graphics Software Labs. All rights reserved. **
\****************************************************************************/
#include <stdio.h>
#include "endianio.h"
#include "pcx.h"

VOID (*PutWord)(WORD, FILE *); /* Pointer to ENDIANIO function */

/*
** Write the information from a PCX image file structure.
**
** PCX header file information is read from the supplied PCX
** header structure and written to the supplied FILE stream.
** The ENDIANIO I/O finctions are used to insure that the header
** information is written in little-endian order.
**
** Returns: Nothing.
*/
VOID
WritePcxHeader(PcxHead, FpPcx)
PCXHEADER *PcxHead; /* Pointer to PCX header structure */
FILE *FpPcx; /* PCX image file output FILE stream */
{
register SHORT i;

PutWord = PutLittleWord; /* Initialize ENDIANIO write function */

PutByte(PcxHead->Id, FpPcx);
PutByte(PcxHead->Version, FpPcx);
PutByte(PcxHead->Format, FpPcx);
PutByte(PcxHead->BitsPixelPlane, FpPcx);
PutWord(PcxHead->Xmin, FpPcx);
PutWord(PcxHead->Ymin, FpPcx);
PutWord(PcxHead->Xmax, FpPcx);
PutWord(PcxHead->Ymax, FpPcx);
PutWord(PcxHead->Hdpi, FpPcx);
PutWord(PcxHead->Vdpi, FpPcx);

/* Write the EGA Palette */
for (i = 0; i < sizeof(PcxHead->EgaPalette); i++)
PutByte(PcxHead->EgaPalette[i], FpPcx);

PutByte(PcxHead->Reserved, FpPcx);
PutByte(PcxHead->NumberOfPlanes, FpPcx);
PutWord(PcxHead->BytesLinePlane, FpPcx);
PutWord(PcxHead->PaletteInfo, FpPcx);
PutWord(PcxHead->HScreenSize, FpPcx);
PutWord(PcxHead->VScreenSize, FpPcx);

/* Write the reserved area at the end of the header */
for (i = 0; i < sizeof(PcxHead->Filler); i++)
PutByte(PcxHead->Filler[i], FpPcx);
}

}

thx all ::oops::

anna_ht
14-03-2007, 07:39 PM
hehe, masalah yg robby dah terselesaikan,..
aq mo tanya ni soal C,. ad yg bs ubah program dlm C ini ke bhs Pascal ato psedu code???
(o ya, aq jg lg crt struktur penyimpanan ekstensi PCX, bagi yg tau, boleh bagi2 dunk ::oops:: )

/****************************************************************************\
** Title: PCXWRITE.C **
** Purpose: Write PCX header information to a file. **
** Version: 1.0 **
** Date: May 1991 **
** Author: James D. Murray, Anaheim, CA USA **
** C Compilers: Borland C++ v2.0, Microsoft C v6.00a **
** **
** Write the information contained within a PCXHEADER structure to a file. **
** **
** This module contains the following functions: **
** **
** WritePcxHeader - Write a PCX header to a file stream **
** **
** Copyright (C) 1991 by Graphics Software Labs. All rights reserved. **
\****************************************************************************/
#include <stdio.h>
#include "endianio.h"
#include "pcx.h"

VOID (*PutWord)(WORD, FILE *); /* Pointer to ENDIANIO function */

/*
** Write the information from a PCX image file structure.
**
** PCX header file information is read from the supplied PCX
** header structure and written to the supplied FILE stream.
** The ENDIANIO I/O finctions are used to insure that the header
** information is written in little-endian order.
**
** Returns: Nothing.
*/
VOID
WritePcxHeader(PcxHead, FpPcx)
PCXHEADER *PcxHead; /* Pointer to PCX header structure */
FILE *FpPcx; /* PCX image file output FILE stream */
{
register SHORT i;

PutWord = PutLittleWord; /* Initialize ENDIANIO write function */

PutByte(PcxHead->Id, FpPcx);
PutByte(PcxHead->Version, FpPcx);
PutByte(PcxHead->Format, FpPcx);
PutByte(PcxHead->BitsPixelPlane, FpPcx);
PutWord(PcxHead->Xmin, FpPcx);
PutWord(PcxHead->Ymin, FpPcx);
PutWord(PcxHead->Xmax, FpPcx);
PutWord(PcxHead->Ymax, FpPcx);
PutWord(PcxHead->Hdpi, FpPcx);
PutWord(PcxHead->Vdpi, FpPcx);

/* Write the EGA Palette */
for (i = 0; i < sizeof(PcxHead->EgaPalette); i++)
PutByte(PcxHead->EgaPalette[i], FpPcx);

PutByte(PcxHead->Reserved, FpPcx);
PutByte(PcxHead->NumberOfPlanes, FpPcx);
PutWord(PcxHead->BytesLinePlane, FpPcx);
PutWord(PcxHead->PaletteInfo, FpPcx);
PutWord(PcxHead->HScreenSize, FpPcx);
PutWord(PcxHead->VScreenSize, FpPcx);

/* Write the reserved area at the end of the header */
for (i = 0; i < sizeof(PcxHead->Filler); i++)
PutByte(PcxHead->Filler[i], FpPcx);
}

}

thx all ::oops::

ruboW
15-03-2007, 10:53 AM
hehe, masalah yg robby dah terselesaikan,..

(o ya, aq jg lg crt struktur penyimpanan ekstensi PCX, bagi yg tau, boleh bagi2 dunk ::oops:: )

/****************************************************************************\
** Title: PCXWRITE.C **
** Purpose: Write PCX header information to a file. **
** Version: 1.0 **
** Date: May 1991 **
** Author: James D. Murray, Anaheim, CA USA **
** C Compilers: Borland C++ v2.0, Microsoft C v6.00a **
** **
** Write the information contained within a PCXHEADER structure to a file. **
** **
** This module contains the following functions: **
** **
** WritePcxHeader - Write a PCX header to a file stream **
** **
** Copyright (C) 1991 by Graphics Software Labs. All rights reserved. **
\****************************************************************************/
#include <stdio.h>
#include "endianio.h"
#include "pcx.h"

VOID (*PutWord)(WORD, FILE *); /* Pointer to ENDIANIO function */

/*
** Write the information from a PCX image file structure.
**
** PCX header file information is read from the supplied PCX
** header structure and written to the supplied FILE stream.
** The ENDIANIO I/O finctions are used to insure that the header
** information is written in little-endian order.
**
** Returns: Nothing.
*/
VOID
WritePcxHeader(PcxHead, FpPcx)
PCXHEADER *PcxHead; /* Pointer to PCX header structure */
FILE *FpPcx; /* PCX image file output FILE stream */
{
register SHORT i;

PutWord = PutLittleWord; /* Initialize ENDIANIO write function */

PutByte(PcxHead->Id, FpPcx);
PutByte(PcxHead->Version, FpPcx);
PutByte(PcxHead->Format, FpPcx);
PutByte(PcxHead->BitsPixelPlane, FpPcx);
PutWord(PcxHead->Xmin, FpPcx);
PutWord(PcxHead->Ymin, FpPcx);
PutWord(PcxHead->Xmax, FpPcx);
PutWord(PcxHead->Ymax, FpPcx);
PutWord(PcxHead->Hdpi, FpPcx);
PutWord(PcxHead->Vdpi, FpPcx);

/* Write the EGA Palette */
for (i = 0; i < sizeof(PcxHead->EgaPalette); i++)
PutByte(PcxHead->EgaPalette[i], FpPcx);

PutByte(PcxHead->Reserved, FpPcx);
PutByte(PcxHead->NumberOfPlanes, FpPcx);
PutWord(PcxHead->BytesLinePlane, FpPcx);
PutWord(PcxHead->PaletteInfo, FpPcx);
PutWord(PcxHead->HScreenSize, FpPcx);
PutWord(PcxHead->VScreenSize, FpPcx);

/* Write the reserved area at the end of the header */
for (i = 0; i < sizeof(PcxHead->Filler); i++)
PutByte(PcxHead->Filler[i], FpPcx);
}

}

thx all ::oops::****************************************************************************\
** Title: PCXWRITE.C **
** Purpose: Write PCX header information to a file. **
** Version: 1.0 **
** Date: May 1991 **
** Author: James D. Murray, Anaheim, CA USA **
** C Compilers: Borland C++ v2.0, Microsoft C v6.00a **
** **
** Write the information contained within a PCXHEADER structure to a file. **
** **
** This module contains the following functions: **
** **
** WritePcxHeader - Write a PCX header to a file stream **
** **
** Copyright (C) 1991 by Graphics Software Labs. All rights reserved. **
\****************************************************************************/

uses crt;

procedure WritePcxHeader(PcxHead, FpPcx)
begin
global SHORT i;
PutByte(PcxHead.Id, FpPcx);
PutByte(PcxHead.Version, FpPcx);
PutByte(PcxHead.Format, FpPcx);
PutByte(PcxHead.BitsPixelPlane, FpPcx);
PutWord(PcxHead.Xmin, FpPcx);
PutWord(PcxHead.Ymin, FpPcx);
PutWord(PcxHead.Xmax, FpPcx);
PutWord(PcxHead.Ymax, FpPcx);
PutWord(PcxHead.Hdpi, FpPcx);
PutWord(PcxHead.Vdpi, FpPcx);

for i:= 0 to i =< sizeof(PcxHead.EgaPalette)
PutByte(PcxHead->EgaPalette[i], FpPcx);

PutByte(PcxHead.Reserved, FpPcx);
PutByte(PcxHead.NumberOfPlanes, FpPcx);
PutWord(PcxHead.BytesLinePlane, FpPcx);
PutWord(PcxHead.PaletteInfo, FpPcx);
PutWord(PcxHead.HScreenSize, FpPcx);
PutWord(PcxHead.VScreenSize, FpPcx);

for i:= 0 to i = sizeof(PcxHead.Filler)
PutByte(PcxHead->Filler[i], FpPcx);



end;

aq mo tanya ni soal C,. ad yg bs ubah program dlm C ini ke bhs Pascal ato psedu code???tidak menjamin 45%jalan
ingat requestnya

anna_ht
16-03-2007, 11:05 AM
ok, aq cba d,.
thx alot

anna_ht
18-03-2007, 11:46 PM
Ok, qta berdiskusi ttg bhs C aj ya,...
ehm, bsh C tuh kan ad jg C, C++,C#
nah, yg paling srg digunkan itu c++ yo?? np?
Sulit C ato C++??

ruboW
21-03-2007, 05:08 PM
C itu adalah asal dari bahasa C.. sebenaranya ada yg bahasa B sih..
C ini ternyata memiliki kekurangan. dia tak mampu membuat prog besar dan dibuat C++ untuk menangani masalah itu.

untuk c# (sharp) belum ada ide kenapa muncul.. kemungkinan kaerna munculnya dot NET yg mewabah cmiiw

opera
22-03-2007, 02:36 PM
C itu adalah asal dari bahasa C.. sebenaranya ada yg bahasa B sih..
C ini ternyata memiliki kekurangan. dia tak mampu membuat prog besar dan dibuat C++ untuk menangani masalah itu.

untuk c# (sharp) belum ada ide kenapa muncul.. kemungkinan kaerna munculnya dot NET yg mewabah cmiiw


ah masa ga ada bahasa B
gua aja sempe belajar
http://en.wikipedia.org/wiki/B_programming_language

anna_ht
22-03-2007, 03:11 PM
Ehm, C itu rumit??
Lbh sulit Java ato C ??

GitzJoey
22-03-2007, 04:01 PM
Java itu kembangan dari C++
Java dengan C# bole dibilang cuman beda nama doank :)