build: Remove tinycc/test2 import.
* scaffold/tinycc/: Remove. * build-aux/check-mescc.sh: Remove tinycc testing. * build-aux/check-tcc.sh: New file. * build-aux/check.sh.in: Use it. * build-aux/config.sh: Update. * build-aux/export.make: Update.
This commit is contained in:
parent
f68b169feb
commit
4db4cb9090
|
@ -179,124 +179,6 @@ for t in $tests; do
|
|||
fi
|
||||
done
|
||||
|
||||
tests="
|
||||
00_assignment
|
||||
01_comment
|
||||
02_printf
|
||||
03_struct
|
||||
04_for
|
||||
05_array
|
||||
06_case
|
||||
07_function
|
||||
08_while
|
||||
09_do_while
|
||||
|
||||
10_pointer
|
||||
11_precedence
|
||||
12_hashdefine
|
||||
13_integer_literals
|
||||
14_if
|
||||
15_recursion
|
||||
16_nesting
|
||||
17_enum
|
||||
18_include
|
||||
19_pointer_arithmetic
|
||||
|
||||
20_pointer_comparison
|
||||
21_char_array
|
||||
22_floating_point
|
||||
23_type_coercion
|
||||
24_math_library
|
||||
25_quicksort
|
||||
26_character_constants
|
||||
27_sizeof
|
||||
28_strings
|
||||
29_array_address
|
||||
|
||||
30_hanoi
|
||||
31_args
|
||||
32_led
|
||||
33_ternary_op
|
||||
34_array_assignment
|
||||
35_sizeof
|
||||
36_array_initialisers
|
||||
37_sprintf
|
||||
38_multiple_array_index
|
||||
39_typedef
|
||||
|
||||
40_stdio
|
||||
41_hashif
|
||||
42_function_pointer
|
||||
43_void_param
|
||||
44_scoped_declarations
|
||||
45_empty_for
|
||||
47_switch_return
|
||||
48_nested_break
|
||||
49_bracket_evaluation
|
||||
|
||||
50_logical_second_arg
|
||||
51_static
|
||||
52_unnamed_enum
|
||||
54_goto
|
||||
55_lshift_type
|
||||
"
|
||||
|
||||
broken="$broken
|
||||
18_include
|
||||
|
||||
22_floating_point
|
||||
23_type_coercion
|
||||
24_math_library
|
||||
26_character_constants
|
||||
27_sizeof
|
||||
28_strings
|
||||
|
||||
34_array_assignment
|
||||
39_typedef
|
||||
|
||||
40_stdio
|
||||
42_function_pointer
|
||||
49_bracket_evaluation
|
||||
55_lshift_type
|
||||
"
|
||||
|
||||
#22_floating_point ; float
|
||||
#23_type_coercion ; float
|
||||
#24_math_library ; float
|
||||
#27_sizeof ; float
|
||||
#28_strings ; TODO: strncpy strchr strrchr memset memcpy memcmp
|
||||
#30_hanoi ; fails with GCC
|
||||
#34_array_assignment ; fails with GCC
|
||||
#39_typedef ;unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (typename "MyFunStruct"))) (init-declr-list (init-declr (ptr-declr (pointer) (ident "MoreFunThanEver")))))
|
||||
|
||||
#40_stdio ; f* functions
|
||||
#42_function_pointer ; f* functions
|
||||
#49_bracket_evaluation ; float
|
||||
|
||||
|
||||
LIBC=c+gnu
|
||||
MES_LIBS="-l c+gnu"
|
||||
|
||||
expect=$(echo $broken | wc -w)
|
||||
ARGS="arg1 arg2 arg3 arg4 arg5"
|
||||
export ARGS
|
||||
mkdir -p scaffold/tinycc
|
||||
for t in $tests; do
|
||||
if [ ! -f scaffold/tinycc/"$t.c" ]; then
|
||||
echo ' [SKIP]'
|
||||
continue;
|
||||
fi
|
||||
sh ${srcdest}build-aux/test.sh "scaffold/tinycc/$t" &> scaffold/tinycc/"$t".log
|
||||
r=$?
|
||||
total=$((total+1))
|
||||
if [ $r = 0 ]; then
|
||||
echo $t: [OK]
|
||||
pass=$((pass+1))
|
||||
else
|
||||
echo $t: [FAIL]
|
||||
fail=$((fail+1))
|
||||
fi
|
||||
done
|
||||
[ $expect != 0 ] && echo "expect: $expect"
|
||||
[ $fail != 0 ] && echo "failed: $fail"
|
||||
[ $fail -lt $expect ] && echo "solved: $(($expect - $fail))"
|
||||
|
|
174
build-aux/check-tcc.sh
Executable file
174
build-aux/check-tcc.sh
Executable file
|
@ -0,0 +1,174 @@
|
|||
#! /bin/sh
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
# GNU Mes is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or (at
|
||||
# your option) any later version.
|
||||
#
|
||||
# GNU Mes is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set -e
|
||||
. ${srcdest}build-aux/config.sh
|
||||
. ${srcdest}build-aux/trace.sh
|
||||
|
||||
MES=${MES-src/mes}
|
||||
[ -z "$MESCC" ] && MESCC=scripts/mescc
|
||||
GUILE=${GUILE-guile}
|
||||
MES_PREFIX=${MES_PREFIX-mes}
|
||||
|
||||
HEX2=${HEX2-hex2}
|
||||
M1=${M1-M1}
|
||||
BLOOD_ELF=${BLOOD_ELF-blood-elf}
|
||||
MES_SEED=${MES_SEED-../mes-seed}
|
||||
MESCC=${MESCC-$(command -v mescc)}
|
||||
[ -z "$MESCC" ] && MESCC=scripts/mescc
|
||||
MES=${MES-$(command -v mes)}
|
||||
[ -z "$MES" ] && MES=src/mes
|
||||
|
||||
if ! command -v $GUILE > /dev/null; then
|
||||
GUILE=true
|
||||
fi
|
||||
|
||||
tests="
|
||||
00_assignment
|
||||
01_comment
|
||||
02_printf
|
||||
03_struct
|
||||
04_for
|
||||
05_array
|
||||
06_case
|
||||
07_function
|
||||
08_while
|
||||
09_do_while
|
||||
|
||||
10_pointer
|
||||
11_precedence
|
||||
12_hashdefine
|
||||
13_integer_literals
|
||||
14_if
|
||||
15_recursion
|
||||
16_nesting
|
||||
17_enum
|
||||
18_include
|
||||
19_pointer_arithmetic
|
||||
|
||||
20_pointer_comparison
|
||||
21_char_array
|
||||
22_floating_point
|
||||
23_type_coercion
|
||||
24_math_library
|
||||
25_quicksort
|
||||
26_character_constants
|
||||
27_sizeof
|
||||
28_strings
|
||||
29_array_address
|
||||
|
||||
30_hanoi
|
||||
31_args
|
||||
32_led
|
||||
33_ternary_op
|
||||
34_array_assignment
|
||||
35_sizeof
|
||||
36_array_initialisers
|
||||
37_sprintf
|
||||
38_multiple_array_index
|
||||
39_typedef
|
||||
|
||||
40_stdio
|
||||
41_hashif
|
||||
42_function_pointer
|
||||
43_void_param
|
||||
44_scoped_declarations
|
||||
45_empty_for
|
||||
47_switch_return
|
||||
48_nested_break
|
||||
49_bracket_evaluation
|
||||
|
||||
50_logical_second_arg
|
||||
51_static
|
||||
52_unnamed_enum
|
||||
54_goto
|
||||
55_lshift_type
|
||||
"
|
||||
|
||||
broken="$broken
|
||||
18_include
|
||||
|
||||
22_floating_point
|
||||
23_type_coercion
|
||||
24_math_library
|
||||
26_character_constants
|
||||
27_sizeof
|
||||
28_strings
|
||||
|
||||
34_array_assignment
|
||||
39_typedef
|
||||
|
||||
40_stdio
|
||||
42_function_pointer
|
||||
49_bracket_evaluation
|
||||
55_lshift_type
|
||||
"
|
||||
|
||||
#22_floating_point ; float
|
||||
#23_type_coercion ; float
|
||||
#24_math_library ; float
|
||||
#27_sizeof ; float
|
||||
#28_strings ; TODO: strncpy strchr strrchr memset memcpy memcmp
|
||||
#30_hanoi ; fails with GCC
|
||||
#34_array_assignment ; fails with GCC
|
||||
#39_typedef ;unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (typename "MyFunStruct"))) (init-declr-list (init-declr (ptr-declr (pointer) (ident "MoreFunThanEver")))))
|
||||
|
||||
#40_stdio ; f* functions
|
||||
#42_function_pointer ; f* functions
|
||||
#49_bracket_evaluation ; float
|
||||
|
||||
|
||||
LIBC=c+gnu
|
||||
MES_LIBS="-l c+gnu"
|
||||
|
||||
expect=$(echo $broken | wc -w)
|
||||
ARGS="arg1 arg2 arg3 arg4 arg5"
|
||||
export ARGS
|
||||
mkdir -p scaffold/tinycc
|
||||
for t in $tests; do
|
||||
if [ ! -f $TINYCC_PREFIX/"$t.c" ]; then
|
||||
echo ' [SKIP]'
|
||||
continue;
|
||||
fi
|
||||
cp $TINYCC_PREFIX/tests/tests2/$i* scaffold/tinycc
|
||||
sh ${srcdest}build-aux/test.sh "scaffold/tinycc/$t" &> scaffold/tinycc/"$t".log
|
||||
r=$?
|
||||
total=$((total+1))
|
||||
if [ $r = 0 ]; then
|
||||
echo $t: [OK]
|
||||
pass=$((pass+1))
|
||||
else
|
||||
echo $t: [FAIL]
|
||||
fail=$((fail+1))
|
||||
fi
|
||||
done
|
||||
[ $expect != 0 ] && echo "expect: $expect"
|
||||
[ $fail != 0 ] && echo "failed: $fail"
|
||||
[ $fail -lt $expect ] && echo "solved: $(($expect - $fail))"
|
||||
echo "passed: $pass"
|
||||
echo "total: $total"
|
||||
if [ $fail != 0 -a $fail -gt $expect ]; then
|
||||
echo FAILED: $fail/$total
|
||||
exit 1
|
||||
elif [ $fail != 0 ]; then
|
||||
echo PASS: $pass/$total
|
||||
else
|
||||
echo PASS: $total
|
||||
fi
|
|
@ -32,6 +32,7 @@ prefix=${prefix-@prefix@}
|
|||
GUILE=${GUILE-guile}
|
||||
MES=${MES-src/mes}
|
||||
MES_ARENA=${MES_ARENA-100000000}
|
||||
TCC_PREFIX=${TCC_PREFIX-${srcdest}../tinycc}
|
||||
|
||||
if ! command -v $GUILE > /dev/null; then
|
||||
GUILE=true
|
||||
|
@ -43,3 +44,4 @@ set -e
|
|||
[ "$MES" != guile ] && bash ${srcdest}build-aux/check-mes.sh
|
||||
bash ${srcdest}build-aux/check-boot.sh
|
||||
bash ${srcdest}build-aux/check-mescc.sh
|
||||
[ -d $TINYCC_PREFIX/tests/tests2 ] && bash ${srcdest}build-aux/check-tcc.sh
|
||||
|
|
|
@ -48,6 +48,7 @@ export MES_SEED
|
|||
export MES_ARENA
|
||||
export COMPILE
|
||||
export PREPROCESS
|
||||
export TINYCC_PREFIX
|
||||
export V
|
||||
|
||||
export abs_top_builddir
|
||||
|
|
|
@ -147,3 +147,7 @@ endif
|
|||
ifdef TINYCC_SEED
|
||||
export TINYCC_SEED
|
||||
endif
|
||||
|
||||
ifdef TINYCC_PREFIX
|
||||
export TINYCC_PREFIX
|
||||
endif
|
||||
|
|
6
configure
vendored
6
configure
vendored
|
@ -288,6 +288,7 @@ Some influential environment variables:
|
|||
MES_SEED location of mes-seed
|
||||
MESCC_TOOLS_SEED location of mescc-tools-seed
|
||||
TCC tcc C compiler command
|
||||
TINYCC_PREFIX location of tinycc [for tests/test2]
|
||||
TINYCC_SEED location of tinycc-seed
|
||||
" PACKAGE VERSION (getenv "prefix")))
|
||||
|
||||
|
@ -338,6 +339,8 @@ Some influential environment variables:
|
|||
(for-each (lambda (v) (apply setenv (string-split v #\=))) vars)
|
||||
(let* ((mes-seed (or (getenv "MES_SEED")
|
||||
(string-append srcdest "../mes-seed")))
|
||||
(tinycc-prefix (or (getenv "TINYCC_PREFIX")
|
||||
(string-append srcdest "../tinycc-prefix")))
|
||||
(tinycc-seed (or (getenv "TINYCC_SEED")
|
||||
(string-append srcdest "../tinycc-seed")))
|
||||
(mescc-tools-seed (or (getenv "MESCC_TOOLS_SEED")
|
||||
|
@ -379,6 +382,9 @@ Some influential environment variables:
|
|||
(deps (cons (check-file (make-dep "mescc-tools-seed" '(0) #:optional? #t
|
||||
#:file-name mescc-tools-seed))
|
||||
deps))
|
||||
(deps (cons (check-file (make-dep "tinycc-prefix" '(0) #:optional? #t
|
||||
#:file-name tinycc-prefix))
|
||||
deps))
|
||||
(missing (filter (conjoin (negate dependency-file-name)
|
||||
(negate dependency-optional?)) deps)))
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
a = 42;
|
||||
printf("%d\n", a);
|
||||
|
||||
int b = 64;
|
||||
printf("%d\n", b);
|
||||
|
||||
int c = 12, d = 34;
|
||||
printf("%d, %d\n", c, d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,3 +0,0 @@
|
|||
42
|
||||
64
|
||||
12, 34
|
|
@ -1,14 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello\n");
|
||||
printf("Hello\n"); /* this is a comment */ printf("Hello\n");
|
||||
printf("Hello\n");
|
||||
// this is also a comment sayhello();
|
||||
printf("Hello\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,5 +0,0 @@
|
|||
Hello
|
||||
Hello
|
||||
Hello
|
||||
Hello
|
||||
Hello
|
|
@ -1,18 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello world\n");
|
||||
|
||||
int Count;
|
||||
for (Count = -5; Count <= 5; Count++)
|
||||
printf("Count = %d\n", Count);
|
||||
|
||||
printf("String 'hello', 'there' is '%s', '%s'\n", "hello", "there");
|
||||
printf("Character 'A' is '%c'\n", 65);
|
||||
printf("Character 'a' is '%c'\n", 'a');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,15 +0,0 @@
|
|||
Hello world
|
||||
Count = -5
|
||||
Count = -4
|
||||
Count = -3
|
||||
Count = -2
|
||||
Count = -1
|
||||
Count = 0
|
||||
Count = 1
|
||||
Count = 2
|
||||
Count = 3
|
||||
Count = 4
|
||||
Count = 5
|
||||
String 'hello', 'there' is 'hello', 'there'
|
||||
Character 'A' is 'A'
|
||||
Character 'a' is 'a'
|
|
@ -1,31 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
struct fred
|
||||
{
|
||||
int boris;
|
||||
int natasha;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
struct fred bloggs;
|
||||
|
||||
bloggs.boris = 12;
|
||||
bloggs.natasha = 34;
|
||||
|
||||
printf("%d\n", bloggs.boris);
|
||||
printf("%d\n", bloggs.natasha);
|
||||
|
||||
struct fred jones[2];
|
||||
jones[0].boris = 12;
|
||||
jones[0].natasha = 34;
|
||||
jones[1].boris = 56;
|
||||
jones[1].natasha = 78;
|
||||
|
||||
printf("%d\n", jones[0].boris);
|
||||
printf("%d\n", jones[0].natasha);
|
||||
printf("%d\n", jones[1].boris);
|
||||
printf("%d\n", jones[1].natasha);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
12
|
||||
34
|
||||
12
|
||||
34
|
||||
56
|
||||
78
|
|
@ -1,15 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Count;
|
||||
|
||||
for (Count = 1; Count <= 10; Count++)
|
||||
{
|
||||
printf("%d\n", Count);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,10 +0,0 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
|
@ -1,21 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Count;
|
||||
int Array[10];
|
||||
|
||||
for (Count = 1; Count <= 10; Count++)
|
||||
{
|
||||
Array[Count-1] = Count * Count;
|
||||
}
|
||||
|
||||
for (Count = 0; Count < 10; Count++)
|
||||
{
|
||||
printf("%d\n", Array[Count]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,10 +0,0 @@
|
|||
1
|
||||
4
|
||||
9
|
||||
16
|
||||
25
|
||||
36
|
||||
49
|
||||
64
|
||||
81
|
||||
100
|
|
@ -1,29 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Count;
|
||||
|
||||
for (Count = 0; Count < 4; Count++)
|
||||
{
|
||||
printf("%d\n", Count);
|
||||
switch (Count)
|
||||
{
|
||||
case 1:
|
||||
printf("%d\n", 1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
printf("%d\n", 2);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("%d\n", 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,8 +0,0 @@
|
|||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
3
|
||||
0
|
|
@ -1,30 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int myfunc(int x)
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
|
||||
void vfunc(int a)
|
||||
{
|
||||
printf("a=%d\n", a);
|
||||
}
|
||||
|
||||
void qfunc()
|
||||
{
|
||||
printf("qfunc()\n");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("%d\n", myfunc(3));
|
||||
printf("%d\n", myfunc(4));
|
||||
|
||||
vfunc(1234);
|
||||
|
||||
qfunc();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,4 +0,0 @@
|
|||
9
|
||||
16
|
||||
a=1234
|
||||
qfunc()
|
|
@ -1,24 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
int p;
|
||||
int t;
|
||||
|
||||
a = 1;
|
||||
p = 0;
|
||||
t = 0;
|
||||
|
||||
while (a < 100)
|
||||
{
|
||||
printf("%d\n", a);
|
||||
t = a;
|
||||
a = t + p;
|
||||
p = t;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,11 +0,0 @@
|
|||
1
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
8
|
||||
13
|
||||
21
|
||||
34
|
||||
55
|
||||
89
|
|
@ -1,24 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
int p;
|
||||
int t;
|
||||
|
||||
a = 1;
|
||||
p = 0;
|
||||
t = 0;
|
||||
|
||||
do
|
||||
{
|
||||
printf("%d\n", a);
|
||||
t = a;
|
||||
a = t + p;
|
||||
p = t;
|
||||
} while (a < 100);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,11 +0,0 @@
|
|||
1
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
8
|
||||
13
|
||||
21
|
||||
34
|
||||
55
|
||||
89
|
|
@ -1,40 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
struct ziggy
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
} bolshevic;
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
int *b;
|
||||
int c;
|
||||
|
||||
a = 42;
|
||||
b = &a;
|
||||
printf("a = %d\n", *b);
|
||||
|
||||
bolshevic.a = 12;
|
||||
bolshevic.b = 34;
|
||||
bolshevic.c = 56;
|
||||
|
||||
printf("bolshevic.a = %d\n", bolshevic.a);
|
||||
printf("bolshevic.b = %d\n", bolshevic.b);
|
||||
printf("bolshevic.c = %d\n", bolshevic.c);
|
||||
|
||||
struct ziggy *tsar = &bolshevic;
|
||||
|
||||
printf("tsar->a = %d\n", tsar->a);
|
||||
printf("tsar->b = %d\n", tsar->b);
|
||||
printf("tsar->c = %d\n", tsar->c);
|
||||
|
||||
b = &(bolshevic.b);
|
||||
printf("bolshevic.b = %d\n", *b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,8 +0,0 @@
|
|||
a = 42
|
||||
bolshevic.a = 12
|
||||
bolshevic.b = 34
|
||||
bolshevic.c = 56
|
||||
tsar->a = 12
|
||||
tsar->b = 34
|
||||
tsar->c = 56
|
||||
bolshevic.b = 34
|
|
@ -1,40 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
int e;
|
||||
int f;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
a = 12;
|
||||
b = 34;
|
||||
c = 56;
|
||||
d = 78;
|
||||
e = 0;
|
||||
f = 1;
|
||||
|
||||
printf("%d\n", c + d);
|
||||
printf("%d\n", (y = c + d));
|
||||
printf("%d\n", e || e && f);
|
||||
printf("%d\n", e || f && f);
|
||||
printf("%d\n", e && e || f);
|
||||
printf("%d\n", e && f || f);
|
||||
printf("%d\n", a && f | f);
|
||||
printf("%d\n", a | b ^ c & d);
|
||||
printf("%d, %d\n", a == a, a == b);
|
||||
printf("%d, %d\n", a != a, a != b);
|
||||
printf("%d\n", a != b && c != d);
|
||||
printf("%d\n", a + b * c / f);
|
||||
printf("%d\n", a + b * c / f);
|
||||
printf("%d\n", (4 << 4));
|
||||
printf("%d\n", (64 >> 4));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,15 +0,0 @@
|
|||
134
|
||||
134
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
46
|
||||
1, 0
|
||||
0, 1
|
||||
1
|
||||
1916
|
||||
1916
|
||||
64
|
||||
4
|
|
@ -1,14 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define FRED 12
|
||||
#define BLOGGS(x) (12*(x))
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("%d\n", FRED);
|
||||
printf("%d, %d, %d\n", BLOGGS(1), BLOGGS(2), BLOGGS(3));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,2 +0,0 @@
|
|||
12
|
||||
12, 24, 36
|
|
@ -1,20 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a = 24680;
|
||||
int b = 01234567;
|
||||
int c = 0x2468ac;
|
||||
int d = 0x2468AC;
|
||||
int e = 0b010101010101;
|
||||
|
||||
printf("%d\n", a);
|
||||
printf("%d\n", b);
|
||||
printf("%d\n", c);
|
||||
printf("%d\n", d);
|
||||
printf("%d\n", e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,5 +0,0 @@
|
|||
24680
|
||||
342391
|
||||
2386092
|
||||
2386092
|
||||
1365
|
|
@ -1,21 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a = 1;
|
||||
|
||||
if (a)
|
||||
printf("a is true\n");
|
||||
else
|
||||
printf("a is false\n");
|
||||
|
||||
int b = 0;
|
||||
if (b)
|
||||
printf("b is true\n");
|
||||
else
|
||||
printf("b is false\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
|
|
@ -1,2 +0,0 @@
|
|||
a is true
|
||||
b is false
|
|
@ -1,21 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int factorial(int i)
|
||||
{
|
||||
if (i < 2)
|
||||
return i;
|
||||
else
|
||||
return i * factorial(i - 1);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Count;
|
||||
|
||||
for (Count = 1; Count <= 10; Count++)
|
||||
printf("%d\n", factorial(Count));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,10 +0,0 @@
|
|||
1
|
||||
2
|
||||
6
|
||||
24
|
||||
120
|
||||
720
|
||||
5040
|
||||
40320
|
||||
362880
|
||||
3628800
|
|
@ -1,21 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int x, y, z;
|
||||
|
||||
for (x = 0; x < 2; x++)
|
||||
{
|
||||
for (y = 0; y < 3; y++)
|
||||
{
|
||||
for (z = 0; z < 3; z++)
|
||||
{
|
||||
printf("%d %d %d\n", x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,18 +0,0 @@
|
|||
0 0 0
|
||||
0 0 1
|
||||
0 0 2
|
||||
0 1 0
|
||||
0 1 1
|
||||
0 1 2
|
||||
0 2 0
|
||||
0 2 1
|
||||
0 2 2
|
||||
1 0 0
|
||||
1 0 1
|
||||
1 0 2
|
||||
1 1 0
|
||||
1 1 1
|
||||
1 1 2
|
||||
1 2 0
|
||||
1 2 1
|
||||
1 2 2
|
|
@ -1,29 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
enum fred
|
||||
{
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
e = 54,
|
||||
f = 73,
|
||||
g,
|
||||
h
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
enum fred frod;
|
||||
|
||||
printf("%d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h);
|
||||
/* printf("%d\n", frod); */
|
||||
frod = 12;
|
||||
printf("%d\n", frod);
|
||||
frod = e;
|
||||
printf("%d\n", frod);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,3 +0,0 @@
|
|||
0 1 2 3 54 73 74 75
|
||||
12
|
||||
54
|
|
@ -1,12 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("including\n");
|
||||
#include "18_include.h"
|
||||
printf("done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,3 +0,0 @@
|
|||
including
|
||||
included
|
||||
done
|
|
@ -1 +0,0 @@
|
|||
printf("included\n");
|
|
@ -1,28 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
int *b;
|
||||
int *c;
|
||||
|
||||
a = 42;
|
||||
b = &a;
|
||||
c = NULL;
|
||||
|
||||
printf("%d\n", *b);
|
||||
|
||||
if (b == NULL)
|
||||
printf("b is NULL\n");
|
||||
else
|
||||
printf("b is not NULL\n");
|
||||
|
||||
if (c == NULL)
|
||||
printf("c is NULL\n");
|
||||
else
|
||||
printf("c is not NULL\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,3 +0,0 @@
|
|||
42
|
||||
b is not NULL
|
||||
c is NULL
|
|
@ -1,24 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
int *d;
|
||||
int *e;
|
||||
d = &a;
|
||||
e = &b;
|
||||
a = 12;
|
||||
b = 34;
|
||||
printf("%d\n", *d);
|
||||
printf("%d\n", *e);
|
||||
printf("%d\n", d == e);
|
||||
printf("%d\n", d != e);
|
||||
d = e;
|
||||
printf("%d\n", d == e);
|
||||
printf("%d\n", d != e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,6 +0,0 @@
|
|||
12
|
||||
34
|
||||
0
|
||||
1
|
||||
1
|
||||
0
|
|
@ -1,33 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 'a';
|
||||
char y = x;
|
||||
|
||||
char *a = "hello";
|
||||
|
||||
printf("%s\n", a);
|
||||
|
||||
int c;
|
||||
c = *a;
|
||||
|
||||
char *b;
|
||||
for (b = a; *b != 0; b++)
|
||||
printf("%c: %d\n", *b, *b);
|
||||
|
||||
char destarray[10];
|
||||
char *dest = &destarray[0];
|
||||
char *src = a;
|
||||
|
||||
while (*src != 0)
|
||||
*dest++ = *src++;
|
||||
|
||||
*dest = 0;
|
||||
|
||||
printf("copied string is %s\n", destarray);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,7 +0,0 @@
|
|||
hello
|
||||
h: 104
|
||||
e: 101
|
||||
l: 108
|
||||
l: 108
|
||||
o: 111
|
||||
copied string is hello
|
|
@ -1,50 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// variables
|
||||
float a = 12.34 + 56.78;
|
||||
printf("%f\n", a);
|
||||
|
||||
// infix operators
|
||||
printf("%f\n", 12.34 + 56.78);
|
||||
printf("%f\n", 12.34 - 56.78);
|
||||
printf("%f\n", 12.34 * 56.78);
|
||||
printf("%f\n", 12.34 / 56.78);
|
||||
|
||||
// comparison operators
|
||||
printf("%d %d %d %d %d %d\n", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78);
|
||||
printf("%d %d %d %d %d %d\n", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34);
|
||||
printf("%d %d %d %d %d %d\n", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34);
|
||||
|
||||
// assignment operators
|
||||
a = 12.34;
|
||||
a += 56.78;
|
||||
printf("%f\n", a);
|
||||
|
||||
a = 12.34;
|
||||
a -= 56.78;
|
||||
printf("%f\n", a);
|
||||
|
||||
a = 12.34;
|
||||
a *= 56.78;
|
||||
printf("%f\n", a);
|
||||
|
||||
a = 12.34;
|
||||
a /= 56.78;
|
||||
printf("%f\n", a);
|
||||
|
||||
// prefix operators
|
||||
printf("%f\n", +12.34);
|
||||
printf("%f\n", -12.34);
|
||||
|
||||
// type coercion
|
||||
a = 2;
|
||||
printf("%f\n", a);
|
||||
printf("%f\n", sin(2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,16 +0,0 @@
|
|||
69.120003
|
||||
69.120000
|
||||
-44.440000
|
||||
700.665200
|
||||
0.217330
|
||||
1 1 0 0 0 1
|
||||
0 1 1 1 0 0
|
||||
0 0 0 1 1 1
|
||||
69.120003
|
||||
-44.439999
|
||||
700.665222
|
||||
0.217330
|
||||
12.340000
|
||||
-12.340000
|
||||
2.000000
|
||||
0.909297
|
|
@ -1,54 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void charfunc(char a)
|
||||
{
|
||||
printf("char: %c\n", a);
|
||||
}
|
||||
|
||||
void intfunc(int a)
|
||||
{
|
||||
printf("int: %d\n", a);
|
||||
}
|
||||
|
||||
void floatfunc(float a)
|
||||
{
|
||||
printf("float: %f\n", a);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
charfunc('a');
|
||||
charfunc(98);
|
||||
charfunc(99.0);
|
||||
|
||||
intfunc('a');
|
||||
intfunc(98);
|
||||
intfunc(99.0);
|
||||
|
||||
floatfunc('a');
|
||||
floatfunc(98);
|
||||
floatfunc(99.0);
|
||||
|
||||
/* printf("%c %d %f\n", 'a', 'b', 'c'); */
|
||||
/* printf("%c %d %f\n", 97, 98, 99); */
|
||||
/* printf("%c %d %f\n", 97.0, 98.0, 99.0); */
|
||||
|
||||
char b = 97;
|
||||
char c = 97.0;
|
||||
|
||||
printf("%d %d\n", b, c);
|
||||
|
||||
int d = 'a';
|
||||
int e = 97.0;
|
||||
|
||||
printf("%d %d\n", d, e);
|
||||
|
||||
float f = 'a';
|
||||
float g = 97;
|
||||
|
||||
printf("%f %f\n", f, g);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,12 +0,0 @@
|
|||
char: a
|
||||
char: b
|
||||
char: c
|
||||
int: 97
|
||||
int: 98
|
||||
int: 99
|
||||
float: 97.000000
|
||||
float: 98.000000
|
||||
float: 99.000000
|
||||
97 97
|
||||
97 97
|
||||
97.000000 97.000000
|
|
@ -1,30 +0,0 @@
|
|||
#define _ISOC99_SOURCE 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("%f\n", sin(0.12));
|
||||
printf("%f\n", cos(0.12));
|
||||
printf("%f\n", tan(0.12));
|
||||
printf("%f\n", asin(0.12));
|
||||
printf("%f\n", acos(0.12));
|
||||
printf("%f\n", atan(0.12));
|
||||
printf("%f\n", sinh(0.12));
|
||||
printf("%f\n", cosh(0.12));
|
||||
printf("%f\n", tanh(0.12));
|
||||
printf("%f\n", exp(0.12));
|
||||
printf("%f\n", fabs(-0.12));
|
||||
printf("%f\n", log(0.12));
|
||||
printf("%f\n", log10(0.12));
|
||||
printf("%f\n", pow(0.12, 0.12));
|
||||
printf("%f\n", sqrt(0.12));
|
||||
printf("%f\n", round(12.34));
|
||||
printf("%f\n", ceil(12.34));
|
||||
printf("%f\n", floor(12.34));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,18 +0,0 @@
|
|||
0.119712
|
||||
0.992809
|
||||
0.120579
|
||||
0.120290
|
||||
1.450506
|
||||
0.119429
|
||||
0.120288
|
||||
1.007209
|
||||
0.119427
|
||||
1.127497
|
||||
0.120000
|
||||
-2.120264
|
||||
-0.920819
|
||||
0.775357
|
||||
0.346410
|
||||
12.000000
|
||||
13.000000
|
||||
12.000000
|
|
@ -1,83 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int array[16];
|
||||
|
||||
//Swap integer values by array indexes
|
||||
void swap(int a, int b)
|
||||
{
|
||||
int tmp = array[a];
|
||||
array[a] = array[b];
|
||||
array[b] = tmp;
|
||||
}
|
||||
|
||||
//Partition the array into two halves and return the
|
||||
//index about which the array is partitioned
|
||||
int partition(int left, int right)
|
||||
{
|
||||
int pivotIndex = left;
|
||||
int pivotValue = array[pivotIndex];
|
||||
int index = left;
|
||||
int i;
|
||||
|
||||
swap(pivotIndex, right);
|
||||
for(i = left; i < right; i++)
|
||||
{
|
||||
if(array[i] < pivotValue)
|
||||
{
|
||||
swap(i, index);
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
swap(right, index);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
//Quicksort the array
|
||||
void quicksort(int left, int right)
|
||||
{
|
||||
if(left >= right)
|
||||
return;
|
||||
|
||||
int index = partition(left, right);
|
||||
quicksort(left, index - 1);
|
||||
quicksort(index + 1, right);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
|
||||
array[0] = 62;
|
||||
array[1] = 83;
|
||||
array[2] = 4;
|
||||
array[3] = 89;
|
||||
array[4] = 36;
|
||||
array[5] = 21;
|
||||
array[6] = 74;
|
||||
array[7] = 37;
|
||||
array[8] = 65;
|
||||
array[9] = 33;
|
||||
array[10] = 96;
|
||||
array[11] = 38;
|
||||
array[12] = 53;
|
||||
array[13] = 16;
|
||||
array[14] = 74;
|
||||
array[15] = 55;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
printf("%d ", array[i]);
|
||||
|
||||
printf("\n");
|
||||
|
||||
quicksort(0, 15);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
printf("%d ", array[i]);
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,2 +0,0 @@
|
|||
62 83 4 89 36 21 74 37 65 33 96 38 53 16 74 55
|
||||
4 16 21 33 36 37 38 53 55 62 65 74 74 83 89 96
|
|
@ -1,17 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("%d\n", '\1');
|
||||
printf("%d\n", '\10');
|
||||
printf("%d\n", '\100');
|
||||
printf("%d\n", '\x01');
|
||||
printf("%d\n", '\x0e');
|
||||
printf("%d\n", '\x10');
|
||||
printf("%d\n", '\x40');
|
||||
printf("test \x40\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,8 +0,0 @@
|
|||
1
|
||||
8
|
||||
64
|
||||
1
|
||||
14
|
||||
16
|
||||
64
|
||||
test @
|
|
@ -1,18 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char a;
|
||||
int b;
|
||||
double c;
|
||||
|
||||
printf("%d\n", sizeof(a));
|
||||
printf("%d\n", sizeof(b));
|
||||
printf("%d\n", sizeof(c));
|
||||
|
||||
printf("%d\n", sizeof(!a));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,4 +0,0 @@
|
|||
1
|
||||
4
|
||||
8
|
||||
4
|
|
@ -1,45 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char a[10];
|
||||
|
||||
strcpy(a, "hello");
|
||||
printf("%s\n", a);
|
||||
|
||||
strncpy(a, "gosh", 2);
|
||||
printf("%s\n", a);
|
||||
|
||||
printf("%d\n", strcmp(a, "apple") > 0);
|
||||
printf("%d\n", strcmp(a, "goere") > 0);
|
||||
printf("%d\n", strcmp(a, "zebra") < 0);
|
||||
|
||||
printf("%d\n", strlen(a));
|
||||
|
||||
strcat(a, "!");
|
||||
printf("%s\n", a);
|
||||
|
||||
printf("%d\n", strncmp(a, "apple", 2) > 0);
|
||||
printf("%d\n", strncmp(a, "goere", 2) == 0);
|
||||
printf("%d\n", strncmp(a, "goerg", 2) == 0);
|
||||
printf("%d\n", strncmp(a, "zebra", 2) < 0);
|
||||
|
||||
printf("%s\n", strchr(a, 'o'));
|
||||
printf("%s\n", strrchr(a, 'l'));
|
||||
printf("%d\n", strrchr(a, 'x') == NULL);
|
||||
|
||||
memset(&a[1], 'r', 4);
|
||||
printf("%s\n", a);
|
||||
|
||||
memcpy(&a[2], a, 2);
|
||||
printf("%s\n", a);
|
||||
|
||||
printf("%d\n", memcmp(a, "apple", 4) > 0);
|
||||
printf("%d\n", memcmp(a, "grgr", 4) == 0);
|
||||
printf("%d\n", memcmp(a, "zebra", 4) < 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,19 +0,0 @@
|
|||
hello
|
||||
gollo
|
||||
1
|
||||
1
|
||||
1
|
||||
5
|
||||
gollo!
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
ollo!
|
||||
lo!
|
||||
1
|
||||
grrrr!
|
||||
grgrr!
|
||||
1
|
||||
1
|
||||
1
|
|
@ -1,13 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char a[10];
|
||||
strcpy(a, "abcdef");
|
||||
printf("%s\n", &a[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1 +0,0 @@
|
|||
bcdef
|
|
@ -1,122 +0,0 @@
|
|||
/* example from http://barnyard.syr.edu/quickies/hanoi.c */
|
||||
|
||||
/* hanoi.c: solves the tower of hanoi problem. (Programming exercise.) */
|
||||
/* By Terry R. McConnell (12/2/97) */
|
||||
/* Compile: cc -o hanoi hanoi.c */
|
||||
|
||||
/* This program does no error checking. But then, if it's right,
|
||||
it's right ... right ? */
|
||||
|
||||
|
||||
/* The original towers of hanoi problem seems to have been originally posed
|
||||
by one M. Claus in 1883. There is a popular legend that goes along with
|
||||
it that has been often repeated and paraphrased. It goes something like this:
|
||||
In the great temple at Benares there are 3 golden spikes. On one of them,
|
||||
God placed 64 disks increasing in size from bottom to top, at the beginning
|
||||
of time. Since then, and to this day, the priest on duty constantly transfers
|
||||
disks, one at a time, in such a way that no larger disk is ever put on top
|
||||
of a smaller one. When the disks have been transferred entirely to another
|
||||
spike the Universe will come to an end in a large thunderclap.
|
||||
|
||||
This paraphrases the original legend due to DeParville, La Nature, Paris 1884,
|
||||
Part I, 285-286. For this and further information see: Mathematical
|
||||
Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967,
|
||||
303-305.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/* This is the number of "disks" on tower A initially. Taken to be 64 in the
|
||||
* legend. The number of moves required, in general, is 2^N - 1. For N = 64,
|
||||
* this is 18,446,744,073,709,551,615 */
|
||||
#define N 4
|
||||
|
||||
/* These are the three towers. For example if the state of A is 0,1,3,4, that
|
||||
* means that there are three discs on A of sizes 1, 3, and 4. (Think of right
|
||||
* as being the "down" direction.) */
|
||||
int A[N], B[N], C[N];
|
||||
|
||||
void Hanoi(int,int*,int*,int*);
|
||||
|
||||
/* Print the current configuration of A, B, and C to the screen */
|
||||
void PrintAll()
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("A: ");
|
||||
for(i=0;i<N;i++)printf(" %d ",A[i]);
|
||||
printf("\n");
|
||||
|
||||
printf("B: ");
|
||||
for(i=0;i<N;i++)printf(" %d ",B[i]);
|
||||
printf("\n");
|
||||
|
||||
printf("C: ");
|
||||
for(i=0;i<N;i++)printf(" %d ",C[i]);
|
||||
printf("\n");
|
||||
printf("------------------------------------------\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Move the leftmost nonzero element of source to dest, leave behind 0. */
|
||||
/* Returns the value moved (not used.) */
|
||||
int Move(int *source, int *dest)
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
|
||||
while (i<N && (source[i])==0) i++;
|
||||
while (j<N && (dest[j])==0) j++;
|
||||
|
||||
dest[j-1] = source[i];
|
||||
source[i] = 0;
|
||||
PrintAll(); /* Print configuration after each move. */
|
||||
return dest[j-1];
|
||||
}
|
||||
|
||||
|
||||
/* Moves first n nonzero numbers from source to dest using the rules of Hanoi.
|
||||
Calls itself recursively.
|
||||
*/
|
||||
void Hanoi(int n,int *source, int *dest, int *spare)
|
||||
{
|
||||
int i;
|
||||
if(n==1){
|
||||
Move(source,dest);
|
||||
return;
|
||||
}
|
||||
|
||||
Hanoi(n-1,source,spare,dest);
|
||||
Move(source,dest);
|
||||
Hanoi(n-1,spare,dest,source);
|
||||
return;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
|
||||
/* initialize the towers */
|
||||
for(i=0;i<N;i++)A[i]=i+1;
|
||||
for(i=0;i<N;i++)B[i]=0;
|
||||
for(i=0;i<N;i++)C[i]=0;
|
||||
|
||||
printf("Solution of Tower of Hanoi Problem with %d Disks\n\n",N);
|
||||
|
||||
/* Print the starting state */
|
||||
printf("Starting state:\n");
|
||||
PrintAll();
|
||||
printf("\n\nSubsequent states:\n\n");
|
||||
|
||||
/* Do it! Use A = Source, B = Destination, C = Spare */
|
||||
Hanoi(N,A,B,C);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,71 +0,0 @@
|
|||
Solution of Tower of Hanoi Problem with 4 Disks
|
||||
|
||||
Starting state:
|
||||
A: 1 2 3 4
|
||||
B: 0 0 0 0
|
||||
C: 0 0 0 0
|
||||
------------------------------------------
|
||||
|
||||
|
||||
Subsequent states:
|
||||
|
||||
A: 0 2 3 4
|
||||
B: 0 0 0 0
|
||||
C: 0 0 0 1
|
||||
------------------------------------------
|
||||
A: 0 0 3 4
|
||||
B: 0 0 0 2
|
||||
C: 0 0 0 1
|
||||
------------------------------------------
|
||||
A: 0 0 3 4
|
||||
B: 0 0 1 2
|
||||
C: 0 0 0 0
|
||||
------------------------------------------
|
||||
A: 0 0 0 4
|
||||
B: 0 0 1 2
|
||||
C: 0 0 0 3
|
||||
------------------------------------------
|
||||
A: 0 0 1 4
|
||||
B: 0 0 0 2
|
||||
C: 0 0 0 3
|
||||
------------------------------------------
|
||||
A: 0 0 1 4
|
||||
B: 0 0 0 0
|
||||
C: 0 0 2 3
|
||||
------------------------------------------
|
||||
A: 0 0 0 4
|
||||
B: 0 0 0 0
|
||||
C: 0 1 2 3
|
||||
------------------------------------------
|
||||
A: 0 0 0 0
|
||||
B: 0 0 0 4
|
||||
C: 0 1 2 3
|
||||
------------------------------------------
|
||||
A: 0 0 0 0
|
||||
B: 0 0 1 4
|
||||
C: 0 0 2 3
|
||||
------------------------------------------
|
||||
A: 0 0 0 2
|
||||
B: 0 0 1 4
|
||||
C: 0 0 0 3
|
||||
------------------------------------------
|
||||
A: 0 0 1 2
|
||||
B: 0 0 0 4
|
||||
C: 0 0 0 3
|
||||
------------------------------------------
|
||||
A: 0 0 1 2
|
||||
B: 0 0 3 4
|
||||
C: 0 0 0 0
|
||||
------------------------------------------
|
||||
A: 0 0 0 2
|
||||
B: 0 0 3 4
|
||||
C: 0 0 0 1
|
||||
------------------------------------------
|
||||
A: 0 0 0 0
|
||||
B: 0 2 3 4
|
||||
C: 0 0 0 1
|
||||
------------------------------------------
|
||||
A: 0 0 0 0
|
||||
B: 1 2 3 4
|
||||
C: 0 0 0 0
|
||||
------------------------------------------
|
|
@ -1,14 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int Count;
|
||||
|
||||
printf("hello world %d\n", argc);
|
||||
for (Count = 1; Count < argc; Count++)
|
||||
printf("arg %d: %s\n", Count, argv[Count]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,6 +0,0 @@
|
|||
hello world 6
|
||||
arg 1: arg1
|
||||
arg 2: arg2
|
||||
arg 3: arg3
|
||||
arg 4: arg4
|
||||
arg 5: arg5
|
|
@ -1,266 +0,0 @@
|
|||
/* example from http://barnyard.syr.edu/quickies/led.c */
|
||||
|
||||
/* led.c: print out number as if on 7 line led display. I.e., write integer
|
||||
given on command line like this:
|
||||
_ _ _
|
||||
| _| _| |_| |_
|
||||
| |_ _| | _| etc.
|
||||
|
||||
We assume the terminal behaves like a classical teletype. So the top
|
||||
lines of all digits have to be printed first, then the middle lines of
|
||||
all digits, etc.
|
||||
|
||||
By Terry R. McConnell
|
||||
|
||||
compile: cc -o led led.c
|
||||
|
||||
If you just want to link in the subroutine print_led that does all the
|
||||
work, compile with -DNO_MAIN, and declare the following in any source file
|
||||
that uses the call:
|
||||
|
||||
extern void print_led(unsigned long x, char *buf);
|
||||
|
||||
Bug: you cannot call repeatedly to print more than one number to a line.
|
||||
That would require curses or some other terminal API that allows moving the
|
||||
cursor to a previous line.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_DIGITS 32
|
||||
#define NO_MAIN
|
||||
|
||||
|
||||
/* Print the top line of the digit d into buffer.
|
||||
Does not null terminate buffer. */
|
||||
|
||||
void topline(int d, char *p){
|
||||
|
||||
*p++ = ' ';
|
||||
switch(d){
|
||||
|
||||
/* all these have _ on top line */
|
||||
|
||||
case 0:
|
||||
case 2:
|
||||
case 3:
|
||||
case 5:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
*p++ = '_';
|
||||
break;
|
||||
default:
|
||||
*p++=' ';
|
||||
|
||||
}
|
||||
*p++=' ';
|
||||
}
|
||||
|
||||
/* Print the middle line of the digit d into the buffer.
|
||||
Does not null terminate. */
|
||||
|
||||
void midline(int d, char *p){
|
||||
|
||||
switch(d){
|
||||
|
||||
/* those that have leading | on middle line */
|
||||
|
||||
case 0:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 8:
|
||||
case 9:
|
||||
*p++='|';
|
||||
break;
|
||||
default:
|
||||
*p++=' ';
|
||||
}
|
||||
switch(d){
|
||||
|
||||
/* those that have _ on middle line */
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 8:
|
||||
case 9:
|
||||
*p++='_';
|
||||
break;
|
||||
default:
|
||||
*p++=' ';
|
||||
|
||||
}
|
||||
switch(d){
|
||||
|
||||
/* those that have closing | on middle line */
|
||||
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
*p++='|';
|
||||
break;
|
||||
default:
|
||||
*p++=' ';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Print the bottom line of the digit d. Does not null terminate. */
|
||||
|
||||
void botline(int d, char *p){
|
||||
|
||||
|
||||
switch(d){
|
||||
|
||||
/* those that have leading | on bottom line */
|
||||
|
||||
case 0:
|
||||
case 2:
|
||||
case 6:
|
||||
case 8:
|
||||
*p++='|';
|
||||
break;
|
||||
default:
|
||||
*p++=' ';
|
||||
}
|
||||
switch(d){
|
||||
|
||||
/* those that have _ on bottom line */
|
||||
|
||||
case 0:
|
||||
case 2:
|
||||
case 3:
|
||||
case 5:
|
||||
case 6:
|
||||
case 8:
|
||||
*p++='_';
|
||||
break;
|
||||
default:
|
||||
*p++=' ';
|
||||
|
||||
}
|
||||
switch(d){
|
||||
|
||||
/* those that have closing | on bottom line */
|
||||
|
||||
case 0:
|
||||
case 1:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
*p++='|';
|
||||
break;
|
||||
default:
|
||||
*p++=' ';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the led representation of integer to string buffer. */
|
||||
|
||||
void print_led(unsigned long x, char *buf)
|
||||
{
|
||||
|
||||
int i=0,n;
|
||||
static int d[MAX_DIGITS];
|
||||
|
||||
|
||||
/* extract digits from x */
|
||||
|
||||
n = ( x == 0L ? 1 : 0 ); /* 0 is a digit, hence a special case */
|
||||
|
||||
while(x){
|
||||
d[n++] = (int)(x%10L);
|
||||
if(n >= MAX_DIGITS)break;
|
||||
x = x/10L;
|
||||
}
|
||||
|
||||
/* print top lines of all digits */
|
||||
|
||||
for(i=n-1;i>=0;i--){
|
||||
topline(d[i],buf);
|
||||
buf += 3;
|
||||
*buf++=' ';
|
||||
}
|
||||
*buf++='\n'; /* move teletype to next line */
|
||||
|
||||
/* print middle lines of all digits */
|
||||
|
||||
for(i=n-1;i>=0;i--){
|
||||
midline(d[i],buf);
|
||||
buf += 3;
|
||||
*buf++=' ';
|
||||
}
|
||||
*buf++='\n';
|
||||
|
||||
/* print bottom lines of all digits */
|
||||
|
||||
for(i=n-1;i>=0;i--){
|
||||
botline(d[i],buf);
|
||||
buf += 3;
|
||||
*buf++=' ';
|
||||
}
|
||||
*buf++='\n';
|
||||
*buf='\0';
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char buf[5*MAX_DIGITS];
|
||||
print_led(1234567, buf);
|
||||
printf("%s\n",buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef NO_MAIN
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
int i=0,n;
|
||||
long x;
|
||||
static int d[MAX_DIGITS];
|
||||
char buf[5*MAX_DIGITS];
|
||||
|
||||
if(argc != 2){
|
||||
fprintf(stderr,"led: usage: led integer\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* fetch argument from command line */
|
||||
|
||||
x = atol(argv[1]);
|
||||
|
||||
/* sanity check */
|
||||
|
||||
if(x<0){
|
||||
fprintf(stderr,"led: %d must be non-negative\n",x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
print_led(x,buf);
|
||||
printf("%s\n",buf);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,4 +0,0 @@
|
|||
_ _ _ _
|
||||
| _| _| |_| |_ |_ |
|
||||
| |_ _| | _| |_| |
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Count;
|
||||
|
||||
for (Count = 0; Count < 10; Count++)
|
||||
{
|
||||
printf("%d\n", (Count < 5) ? (Count*Count) : (Count * 3));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,10 +0,0 @@
|
|||
0
|
||||
1
|
||||
4
|
||||
9
|
||||
16
|
||||
15
|
||||
18
|
||||
21
|
||||
24
|
||||
27
|
|
@ -1,23 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a[4];
|
||||
|
||||
a[0] = 12;
|
||||
a[1] = 23;
|
||||
a[2] = 34;
|
||||
a[3] = 45;
|
||||
|
||||
printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]);
|
||||
|
||||
int b[4];
|
||||
|
||||
b = a;
|
||||
|
||||
printf("%d %d %d %d\n", b[0], b[1], b[2], b[3]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,2 +0,0 @@
|
|||
12 23 34 45
|
||||
12 23 34 45
|
|
@ -1,14 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char a;
|
||||
short b;
|
||||
|
||||
printf("%d %d\n", sizeof(char), sizeof(a));
|
||||
printf("%d %d\n", sizeof(short), sizeof(b));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,2 +0,0 @@
|
|||
1 1
|
||||
2 2
|
|
@ -1,21 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Count;
|
||||
|
||||
int Array[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753 };
|
||||
|
||||
for (Count = 0; Count < 10; Count++)
|
||||
printf("%d: %d\n", Count, Array[Count]);
|
||||
|
||||
int Array2[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753, };
|
||||
|
||||
for (Count = 0; Count < 10; Count++)
|
||||
printf("%d: %d\n", Count, Array2[Count]);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,20 +0,0 @@
|
|||
0: 12
|
||||
1: 34
|
||||
2: 56
|
||||
3: 78
|
||||
4: 90
|
||||
5: 123
|
||||
6: 456
|
||||
7: 789
|
||||
8: 8642
|
||||
9: 9753
|
||||
0: 12
|
||||
1: 34
|
||||
2: 56
|
||||
3: 78
|
||||
4: 90
|
||||
5: 123
|
||||
6: 456
|
||||
7: 789
|
||||
8: 8642
|
||||
9: 9753
|
|
@ -1,17 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char Buf[100];
|
||||
int Count;
|
||||
|
||||
for (Count = 1; Count <= 20; Count++)
|
||||
{
|
||||
sprintf(Buf, "->%02d<-\n", Count);
|
||||
printf("%s", Buf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,20 +0,0 @@
|
|||
->01<-
|
||||
->02<-
|
||||
->03<-
|
||||
->04<-
|
||||
->05<-
|
||||
->06<-
|
||||
->07<-
|
||||
->08<-
|
||||
->09<-
|
||||
->10<-
|
||||
->11<-
|
||||
->12<-
|
||||
->13<-
|
||||
->14<-
|
||||
->15<-
|
||||
->16<-
|
||||
->17<-
|
||||
->18<-
|
||||
->19<-
|
||||
->20<-
|
|
@ -1,32 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a[4][4];
|
||||
int b = 0;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
for (x = 0; x < 4; x++)
|
||||
{
|
||||
for (y = 0; y < 4; y++)
|
||||
{
|
||||
b++;
|
||||
a[x][y] = b;
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; x < 4; x++)
|
||||
{
|
||||
printf("x=%d: ", x);
|
||||
for (y = 0; y < 4; y++)
|
||||
{
|
||||
printf("%d ", a[x][y]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,4 +0,0 @@
|
|||
x=0: 1 2 3 4
|
||||
x=1: 5 6 7 8
|
||||
x=2: 9 10 11 12
|
||||
x=3: 13 14 15 16
|
|
@ -1,47 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
typedef int MyInt;
|
||||
|
||||
struct FunStruct
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
};
|
||||
|
||||
typedef struct FunStruct MyFunStruct;
|
||||
|
||||
typedef MyFunStruct *MoreFunThanEver;
|
||||
|
||||
int main()
|
||||
{
|
||||
MyInt a = 1;
|
||||
printf("%d\n", a);
|
||||
|
||||
MyFunStruct b;
|
||||
b.i = 12;
|
||||
b.j = 34;
|
||||
printf("%d,%d\n", b.i, b.j);
|
||||
|
||||
MoreFunThanEver c = &b;
|
||||
printf("%d,%d\n", c->i, c->j);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* "If the specification of an array type includes any type qualifiers,
|
||||
the element type is so-qualified, not the array type." */
|
||||
|
||||
typedef int A[3];
|
||||
extern A const ca;
|
||||
extern const A ca;
|
||||
extern const int ca[3];
|
||||
|
||||
typedef A B[1][2];
|
||||
extern B const cb;
|
||||
extern const B cb;
|
||||
extern const int cb[1][2][3];
|
||||
|
||||
extern B b;
|
||||
extern int b[1][2][3];
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,3 +0,0 @@
|
|||
1
|
||||
12,34
|
||||
12,34
|
|
@ -1,52 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE *f = fopen("fred.txt", "w");
|
||||
fwrite("hello\nhello\n", 1, 12, f);
|
||||
fclose(f);
|
||||
|
||||
char freddy[7];
|
||||
f = fopen("fred.txt", "r");
|
||||
if (fread(freddy, 1, 6, f) != 6)
|
||||
printf("couldn't read fred.txt\n");
|
||||
|
||||
freddy[6] = '\0';
|
||||
fclose(f);
|
||||
|
||||
printf("%s", freddy);
|
||||
|
||||
int InChar;
|
||||
char ShowChar;
|
||||
f = fopen("fred.txt", "r");
|
||||
while ( (InChar = fgetc(f)) != EOF)
|
||||
{
|
||||
ShowChar = InChar;
|
||||
if (ShowChar < ' ')
|
||||
ShowChar = '.';
|
||||
|
||||
printf("ch: %d '%c'\n", InChar, ShowChar);
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
f = fopen("fred.txt", "r");
|
||||
while ( (InChar = getc(f)) != EOF)
|
||||
{
|
||||
ShowChar = InChar;
|
||||
if (ShowChar < ' ')
|
||||
ShowChar = '.';
|
||||
|
||||
printf("ch: %d '%c'\n", InChar, ShowChar);
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
f = fopen("fred.txt", "r");
|
||||
while (fgets(freddy, sizeof(freddy), f) != NULL)
|
||||
printf("x: %s", freddy);
|
||||
|
||||
fclose(f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,27 +0,0 @@
|
|||
hello
|
||||
ch: 104 'h'
|
||||
ch: 101 'e'
|
||||
ch: 108 'l'
|
||||
ch: 108 'l'
|
||||
ch: 111 'o'
|
||||
ch: 10 '.'
|
||||
ch: 104 'h'
|
||||
ch: 101 'e'
|
||||
ch: 108 'l'
|
||||
ch: 108 'l'
|
||||
ch: 111 'o'
|
||||
ch: 10 '.'
|
||||
ch: 104 'h'
|
||||
ch: 101 'e'
|
||||
ch: 108 'l'
|
||||
ch: 108 'l'
|
||||
ch: 111 'o'
|
||||
ch: 10 '.'
|
||||
ch: 104 'h'
|
||||
ch: 101 'e'
|
||||
ch: 108 'l'
|
||||
ch: 108 'l'
|
||||
ch: 111 'o'
|
||||
ch: 10 '.'
|
||||
x: hello
|
||||
x: hello
|
|
@ -1,85 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("#include test\n");
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
printf("a\n");
|
||||
#else
|
||||
printf("b\n");
|
||||
#endif
|
||||
#else
|
||||
#if 0
|
||||
printf("c\n");
|
||||
#else
|
||||
printf("d\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
printf("e\n");
|
||||
#else
|
||||
printf("f\n");
|
||||
#endif
|
||||
#else
|
||||
#if 1
|
||||
printf("g\n");
|
||||
#else
|
||||
printf("h\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DEF
|
||||
|
||||
#ifdef DEF
|
||||
#ifdef DEF
|
||||
printf("i\n");
|
||||
#else
|
||||
printf("j\n");
|
||||
#endif
|
||||
#else
|
||||
#ifdef DEF
|
||||
printf("k\n");
|
||||
#else
|
||||
printf("l\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DEF
|
||||
#ifndef DEF
|
||||
printf("m\n");
|
||||
#else
|
||||
printf("n\n");
|
||||
#endif
|
||||
#else
|
||||
#ifndef DEF
|
||||
printf("o\n");
|
||||
#else
|
||||
printf("p\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define ONE 1
|
||||
#define ZERO 0
|
||||
|
||||
#if ONE
|
||||
#if ZERO
|
||||
printf("q\n");
|
||||
#else
|
||||
printf("r\n");
|
||||
#endif
|
||||
#else
|
||||
#if ZERO
|
||||
printf("s\n");
|
||||
#else
|
||||
printf("t\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,6 +0,0 @@
|
|||
#include test
|
||||
b
|
||||
g
|
||||
i
|
||||
p
|
||||
r
|
|
@ -1,22 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int fred(int p)
|
||||
{
|
||||
printf("yo %d\n", p);
|
||||
return 42;
|
||||
}
|
||||
|
||||
int (*f)(int) = &fred;
|
||||
|
||||
/* To test what this is supposed to test the destination function
|
||||
(fprint here) must not be called directly anywhere in the test. */
|
||||
int (*fprintfptr)(FILE *, const char *, ...) = &fprintf;
|
||||
|
||||
int main()
|
||||
{
|
||||
fprintfptr(stdout, "%d\n", (*f)(24));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,2 +0,0 @@
|
|||
yo 24
|
||||
42
|
|
@ -1,15 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void fred(void)
|
||||
{
|
||||
printf("yo\n");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
fred();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1 +0,0 @@
|
|||
yo
|
|
@ -1,17 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
|
||||
for (a = 0; a < 2; a++)
|
||||
{
|
||||
int b = a;
|
||||
}
|
||||
|
||||
printf("it's all good\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1 +0,0 @@
|
|||
it's all good
|
|
@ -1,18 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Count = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
Count++;
|
||||
printf("%d\n", Count);
|
||||
if (Count >= 10)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
|
@ -1,10 +0,0 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
|
@ -1,24 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void fred(int x)
|
||||
{
|
||||
switch (x)
|
||||
{
|
||||
case 1: printf("1\n"); return;
|
||||
case 2: printf("2\n"); break;
|
||||
case 3: printf("3\n"); return;
|
||||
}
|
||||
|
||||
printf("out\n");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
fred(1);
|
||||
fred(2);
|
||||
fred(3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue