- Testreports
- Funktionen
- Arrays
- Strings
- Bitoperationen
6a7, 1,6c1,6, 6d5?diff).a (append), d (delete) und c (change)
CHANCE #1
description:
check whether output is correct
summary:
[FAILED] comparing "$STDOUT"
compares:
< REFERENCE
> USER CREATED
#0: 6d5
6a7: Nach der 6. Zeile der Musterausgabe, müsste die folgende 7. Zeile angehängt werden (Zeile folgt). Das heißt, ihr gebt dieses Zeile zuviel aus6d5: Die 6. Zeile der Musterausgabe (Zeile folgt) müsste gelöscht werden. Das heißt, ihr gebt eine Zeile nicht aus, obwohl ihr solltet2c2: Die 2. Zeile der Musterausgabe stimmt nicht mit eurer 2. Zeile überein, daraufhin folgt die Zeile der Musterausgabe und eure Zeile
=====================================================================================
TESTCASES
testcase #1 [FAILED]
there were 1 chance(s) to pass testcase
CHANCE #1
description:
check whether output is correct
summary:
[FAILED] return check - ref: 0 user: 255
compares:
< REFERENCE
> USER CREATED
-------------------------------------------------------------------------------------
=====================================================================================
=====================================================================================
TESTCASES
testcase #1 [FAILED]
there were 1 chance(s) to pass testcase
CHANCE #1
description:
check whether output is correct
summary:
[FAILED] comparing "$STDOUT"
compares:
< REFERENCE
> USER CREATED
#0: 6a7
#0: > 1915657434 * 8
-------------------------------------------------------------------------------------
=====================================================================================
OUTPUT
Archive: Term_6/Course_11/Assignment_58/Group_7642/Submission_1_hw1a.zip
inflating: Course_11/Assignment_58/Group_7642/14960/1381852533/hw1a/hw1a.c
Returnvalue was: 0 - should be 0
=====================================================================================
CHECK
check #1
Result:
[FAILED] File hw1a.c not found
=====================================================================================
COMPILE
executable #1
using file_set #1
return was: 1 - should be 0
OUTPUT
gcc44: hw1a.c: No such file or directory
gcc44: no input files
summary:
[FAILED] comparing "$STDOUT"
compares:
< REFERENCE
> USER CREATED
#0: 1,7c1,7
#0: < xxxxxxx * 2
#0: < xxxxxxx * 3
#0: < xxxxxxx * 4
#0: < xxxxxxxx * 5
#0: < xxxxxxxxx * 6
#0: < xxxxxxxxx * 7
#0: < An overflow has occurred!
#0: ---
#0: > xxxxxxx * 2
#0: > xxxxxxx * 3
#0: > xxxxxxx * 4
#0: > xxxxxxxx * 5
#0: > xxxxxxxxx * 6
#0: > xxxxxxxxx * 7
#0: > An overflow has occured!
summary:
[FAILED] comparing "$STDOUT"
compares:
< REFERENCE
> USER CREATED
#0: 1,6c1,6
#0: < xxxxxxx * 2
#0: < xxxxxxx * 3
#0: < xxxxxxx * 4
#0: < xxxxxxxx * 5
#0: < xxxxxxxxx * 6
#0: < xxxxxxxxx * 7
#0: ---
#0: > xxxxxxx * 2
#0: > xxxxxxx * 3
#0: > xxxxxxx * 4
#0: > xxxxxxxx * 5
#0: > xxxxxxxxx * 6
#0: > xxxxxxxxx * 7
<Rueckgabewert-Typ> Funktion-Name (<Parameter1>, <Parameter2>...)
{
// Code
return <Rueckgabewert>
}
int main()
{
// Aufruf:
<Rueckgabewert-Typ> Ergebnis;
Ergebnis = Funktion-Name(<Parameter1>, <Parameter2>...);
}
main-Funktion anzeigen> echo $? 0
<typ> name[<size>];
<typ> name[] = {<value1>, <value2>, ...};name[<index>] = <value>;
|
1int main()
{
2 int fibo[5];
3 fibo[0] = 1;
4 fibo[1] = 1;
5 fibo[2] = fibo[1] + fibo[0];
6 fibo[3] = fibo[2] + fibo[1];
7 fibo[4] = fibo[3] + fibo[2];
return 0;
}
|
|
int size = numberOfHornsOnAUnicorn(); int array[size];
void foo(int bar[]) {
[..]
}
void foo(int bar[8]) {
[..]
}
void foo(int* bar) {
[..]
}<typ> name[<rows>][<columns>];
name[<row>][<column>] = <value>;
char matrix[3][3] = { {'A', 'B', 'C'}, {'D', 'E', 'F'},
{'G', 'H', 'I'} };
int cube[3][3][3]; int hypercube[3][3][3][3];
int hypercube[3][3][3][3];
![]() |
![]() |
![]() |
#include <stdio.h>
void printMatrix3(char matrix[][3])
{
int y;
for(y = 0; y < 3; y++)
{
printf("%c %c %c\n", matrix[y][0], matrix[y][1], matrix[y][2]);
}
}
int main()
{
char matrix[3][3] = { {'A', 'B', 'C'}, {'D', 'E', 'F'},
{'G', 'H', 'I'} };
printMatrix3(matrix);
}
Achtung: Nicht mehr möglich als Pointer zu übergeben!
char (Zeichen)char* text = "Hallo!";
char text[] = "Hallo!";
char text[] = {'H', 'a', 'l', 'l', 'o', '!', '\0'};
strcmp aus string.h verwenden== funktioniert nicht, vergleicht nur die Speicheradressen
char* str1 = "Hello";
char* str2 = "World";
if(strcmp(str1, str2) == 0)
{
// strings sind gleich
}
else
{
// strings sind ungleich
}
[])'\0')char* str1 = "Hello"; char c1 = str[0]; // c1 = 'H' char c2 = str[4]; // c2 = 'o' char c3 = str[5]; // c3 = '\0'
#include <string.h>
&), OR (|), XOR (^)<<), Right Shift (>>)~)| & | 1 | 0 |
|---|---|---|
| 1 | 1 | 0 |
| 0 | 0 | 0 |
| | | 1 | 0 |
|---|---|---|
| 1 | 1 | 1 |
| 0 | 1 | 0 |
| ^ | 1 | 0 |
|---|---|---|
| 1 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | |
|---|---|---|
| ~ | 0 | 1 |
Verschiebt die Bits um n Stellen nach links
Beispiel: 9 ( = 0000 1001b) << 1 = 18 ( = 0001 0010b)
#include <stdio.h>
int main()
{
unsigned char lampen_zustand = 0; // 8 Zustände (Lampen)
// Lampe 1 einschalten
lampen_zustand |= 1;
// Lampen 5-8 ausschalten
lampen_zustand &= 15;
// Lampe 5 umschalten
lampen_zustand ^= 16;
// Zustand ausgeben
int lampe;
for(lampe = 0; lampe < 8; lampe++)
{
printf("Lampe %d: %s\n", lampe + 1,
lampen_zustand & (1 << lampe) ? "ein" : "aus");
}
}
#include <stdio.h>
unsigned int swapByteOrder(unsigned int value)
{
value = ((value << 8) & 0xFF00FF00) |
((value >> 8) & 0xFF00FF);
return (value << 16) | (value >> 16);
}
int main()
{
unsigned int value = 0x12345678;
printf("value = %x\n", value);
printf("swapped value = %x\n", swapByteOrder(value));
return 0;
}
#include <stdio.h>
#define BITS_PER_NIBBLE 4
#define NIBBLE_MASK 0xF
int main()
{
int a_number = 17036401;
int index;
printf("bin = ");
for( index = 32; index > 0; index-- )
{
printf( "%d", (a_number & (1 << (index - 1))) ? 1 : 0 );
if( (index - 1) % BITS_PER_NIBBLE == 0 )
printf(" ");
}
// This should only demonstrate how to use bit operations.
// In practice use %x for hexadecimal output
printf("\nhex = ");
for( index = 32 / BITS_PER_NIBBLE; index > 0; index-- )
{
int nibble = (a_number >> ((index - 1) * BITS_PER_NIBBLE)) & NIBBLE_MASK;
printf( "%4c ", nibble < 10 ? nibble + '0' : nibble + 'A' - 10 );
}
return 0;
}
if((value & (value - 1) == 0)
{
printf("Wann werde ich ausgeführt?");
}
a = a^b; b = b^a; a = a^b;
int log = 0;
while(value > 0)
{
value = value >> 1;
log++;
}
http://graphics.stanford.edu/~seander/bithacks.html
Viel Erfolg beim
ersten Gruppenbeispiel!
Abgabeschluss für Ass1: