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
namespace ConsoleApplication_sort_array | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int[] array = new[] {7,3,9,8,1,10,4,6,2,5}; // 10 unsortierte Elemente | |
foreach (int i in array) // Mit der foreach-Schleife das Array ausgeben | |
{ |
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
/* code001.c ATMega88 @ 8MHz */ | |
#include <avr/io.h> // Einbinden der Headerdatei avr/io.h | |
#include <util/delay.h> // Einbinden der Headerdatei util/delay.h | |
int main(void) // Startpunkt eines C-Programms | |
{ | |
DDRD |= (1<<PD0); // Richtungsregister PORTD PinD0 (Pin2)auf Ausgang setzen | |
while(1) // Beginn der Endlosschleife da while(1) immer wahr ist |
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
/* code002.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> // Einbinden der Headerdatei avr/io.h | |
#include <util/delay.h> // Einbinden der Headerdatei util/delay.h | |
uint8_t x=1, y=0; // Initialisierung der globalen Variablen x und y | |
int main(void) // Startpunkt eines C-Programms | |
{ | |
DDRD |= (1<<PD0); // Richtungsregister PORTD PinD0 auf Ausgang | |
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
/* code003.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
#include <util/delay.h> | |
int main(void) | |
{ | |
DDRD = 0xFF; // Richtungsregister PORTD = 1111 1111 | |
uint8_t data = 0x00; // data = 0 | |
while(1) | |
{ | |
if (data & 0x08) // Maskierung mit 0000 1000 (Bit Nr. 3) |
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
/* code004.c Simulator */ | |
#include <avr/io.h> | |
uint8_t a=2, b=5, hilf; // Deklaration und Initialisierung globaler Variablen | |
int main(void) | |
{ | |
hilf = a; // in hilf wird der Wert von a gespeichert | |
a = b; // in a wird der Wert von b gespeichert | |
b = hilf; // in b wird der Wert von hilf gespeichert |
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
/* code005.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
uint8_t x=2; // Globale Variable x wird deklariert | |
uint8_t addiere(void) | |
{ | |
uint8_t i=2; // (3) i=2 und nur innerhalb der Funktion addiere() gültig | |
x=x+i; // (4) x=4 | |
return i; // (5) i=2 und wird an die aufrufende Funktion übergeben |
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
/* code006.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
uint8_t z1, z2; | |
void zaehler1(void) // Funktion zaehler1 | |
{ | |
uint8_t i = 1; | |
i++; | |
z1=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
/* code007.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
const uint8_t UPPER_LEVEL=200; // Deklaration einer Konstanten mit dem Namen upper_level | |
const uint8_t LOWER_LEVEL=100; // Deklaration einer Konstanten mit dem Namen lower_level | |
int main(void) | |
{ | |
uint8_t data = 110; | |
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
/* code008.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
#define LED1 (PORTD |= (1<<PD0)) // Ersetze (PORTD |= (1<<PD0)) durch LED1 | |
#define LED2 (PORTD |= (1<<PD1)) // Ersetze (PORTD |= (1<<PD1)) durch LED2 | |
#define LED3 (PORTD |= (1<<PD2)) // Ersetze (PORTD |= (1<<PD2)) durch LED3 | |
uint8_t zahl = 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
/* code009.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
uint8_t x=10, y; | |
int main(void) | |
{ | |
/*** Hier die Abfrage in der „Normalform“ ***/ | |
if(x > 8) |
OlderNewer