Skip to content

Commit 5de66d4

Browse files
committed
1 parent 5433260 commit 5de66d4

12 files changed

+784
-0
lines changed

w7countOddNumbers/.dep.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This code depends on make tool being used
2+
DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
3+
ifneq (${DEPFILES},)
4+
include ${DEPFILES}
5+
endif

w7countOddNumbers/Makefile

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#
2+
# There exist several targets which are by default empty and which can be
3+
# used for execution of your targets. These targets are usually executed
4+
# before and after some main targets. They are:
5+
#
6+
# .build-pre: called before 'build' target
7+
# .build-post: called after 'build' target
8+
# .clean-pre: called before 'clean' target
9+
# .clean-post: called after 'clean' target
10+
# .clobber-pre: called before 'clobber' target
11+
# .clobber-post: called after 'clobber' target
12+
# .all-pre: called before 'all' target
13+
# .all-post: called after 'all' target
14+
# .help-pre: called before 'help' target
15+
# .help-post: called after 'help' target
16+
#
17+
# Targets beginning with '.' are not intended to be called on their own.
18+
#
19+
# Main targets can be executed directly, and they are:
20+
#
21+
# build build a specific configuration
22+
# clean remove built files from a configuration
23+
# clobber remove all built files
24+
# all build all configurations
25+
# help print help mesage
26+
#
27+
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28+
# .help-impl are implemented in nbproject/makefile-impl.mk.
29+
#
30+
# Available make variables:
31+
#
32+
# CND_BASEDIR base directory for relative paths
33+
# CND_DISTDIR default top distribution directory (build artifacts)
34+
# CND_BUILDDIR default top build directory (object files, ...)
35+
# CONF name of current configuration
36+
# CND_PLATFORM_${CONF} platform name (current configuration)
37+
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
38+
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
39+
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
40+
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
41+
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
42+
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
43+
#
44+
# NOCDDL
45+
46+
47+
# Environment
48+
MKDIR=mkdir
49+
CP=cp
50+
CCADMIN=CCadmin
51+
52+
53+
# build
54+
build: .build-post
55+
56+
.build-pre:
57+
# Add your pre 'build' code here...
58+
59+
.build-post: .build-impl
60+
# Add your post 'build' code here...
61+
62+
63+
# clean
64+
clean: .clean-post
65+
66+
.clean-pre:
67+
# Add your pre 'clean' code here...
68+
69+
.clean-post: .clean-impl
70+
# Add your post 'clean' code here...
71+
72+
73+
# clobber
74+
clobber: .clobber-post
75+
76+
.clobber-pre:
77+
# Add your pre 'clobber' code here...
78+
79+
.clobber-post: .clobber-impl
80+
# Add your post 'clobber' code here...
81+
82+
83+
# all
84+
all: .all-post
85+
86+
.all-pre:
87+
# Add your pre 'all' code here...
88+
89+
.all-post: .all-impl
90+
# Add your post 'all' code here...
91+
92+
93+
# build tests
94+
build-tests: .build-tests-post
95+
96+
.build-tests-pre:
97+
# Add your pre 'build-tests' code here...
98+
99+
.build-tests-post: .build-tests-impl
100+
# Add your post 'build-tests' code here...
101+
102+
103+
# run tests
104+
test: .test-post
105+
106+
.test-pre:
107+
# Add your pre 'test' code here...
108+
109+
.test-post: .test-impl
110+
# Add your post 'test' code here...
111+
112+
113+
# help
114+
help: .help-post
115+
116+
.help-pre:
117+
# Add your pre 'help' code here...
118+
119+
.help-post: .help-impl
120+
# Add your post 'help' code here...
121+
122+
123+
124+
# include project implementation makefile
125+
include nbproject/Makefile-impl.mk
126+
127+
# include project make variables
128+
include nbproject/Makefile-variables.mk

w7countOddNumbers/main.cpp

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* File: main.cpp
3+
* Author: Lukas Elmer
4+
*
5+
* Created on 30. Juli 2010, 12:12
6+
*/
7+
8+
#include <vector>
9+
#include <iostream>
10+
#include <numeric>
11+
#include <functional>
12+
#include <iomanip>
13+
#include <iterator>
14+
#include <string>
15+
16+
#include <boost/bind.hpp>
17+
using namespace std;
18+
19+
void printDoubles(std::ostream &os, double const &d) {
20+
using namespace std;
21+
os << setw(10) << setprecision(2) << fixed << d << '\n';
22+
}
23+
24+
int main(int argc, char** argv) {
25+
using namespace std;
26+
using namespace boost;
27+
vector<int> v;
28+
v.push_back(10);
29+
v.push_back(8);
30+
v.push_back(12);
31+
v.push_back(1);
32+
v.push_back(3);
33+
v.push_back(5);
34+
35+
// summiert alle zahlen
36+
cout << accumulate(v.begin(), v.end(), 0, plus<int>()) << endl;
37+
// sum + (i*(i%2)), Summiert alle ungerade Zahlen
38+
cout << accumulate(v.begin(), v.end(), 0, bind(plus<int>(), _1, bind(multiplies<int>(), bind(modulus<int>(), _2, 2), _2))) << endl;
39+
// Zählt die Anzahl der ungeraden Zahlen
40+
cout << accumulate(v.begin(), v.end(), 0, bind(plus<int>(), _1, bind(modulus<int>(), _2, 2))) << endl;
41+
cout << count_if(v.begin(), v.end(), bind(modulus<int>(), _1, 2)) << endl;
42+
// Zählt die Anzahl der Zahlen mit Wert 42
43+
cout << count_if(v.begin(), v.end(), bind(equal_to<int>(), _1, 42)) << endl;
44+
45+
vector<double> v2;
46+
// Kopiert alle Werte von v in v2
47+
copy(v.begin(), v.end(), back_inserter(v2));
48+
// Ruft die Funktion printDoubles für alle doubles auf. Achtung: ref für den cout!
49+
for_each(v2.begin(), v2.end(), bind(printDoubles, ref(cout), _1));
50+
51+
// vergleichen Sie zwei strings lexikographisch, ohne gross/kleinschreibung zu unterscheiden.
52+
string s1 = "bla", s2 = "blu";
53+
cout << s1 << " < " << s2 << "? " << lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end()) << endl;
54+
s1 = "bla", s2 = "Blu";
55+
cout << s1 << " < " << s2 << "? (mit gross/kleinschreibung) " <<
56+
lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end()) << endl;
57+
string tmp1 = s1, tmp2 = s2;
58+
transform(tmp1.begin(), tmp1.end(), tmp1.begin(), ::tolower);
59+
transform(tmp2.begin(), tmp2.end(), tmp2.begin(), ::tolower);
60+
cout << s1 << " < " << s2 << "? (ohne gross/kleinschreibung) " <<
61+
lexicographical_compare(tmp1.begin(), tmp1.end(), tmp2.begin(), tmp2.end()) << endl;
62+
63+
//suchen Sie in einem std::string nach aufeinanderfolgenden gleichen Zeichen
64+
// * Nutzen Sie einen passenden Algorithmus!
65+
// * geben Sie alle solche Positionen des std::string aus (braucht eine Schleife)
66+
// output: auee
67+
string s3("blaabluueeez");
68+
string::iterator it = adjacent_find(s3.begin(), s3.end());
69+
while (*it != *s3.end()) {
70+
cout << *it;
71+
it++;
72+
it = adjacent_find(it, s3.end());
73+
}
74+
cout << endl;
75+
76+
//entfernden Sie aus einem vector<int> alle durch 7 teilbaren Zahlen. endgültig.
77+
//vector<int> v;
78+
vector<int> v3;
79+
v.clear();
80+
v.push_back(7);
81+
v.push_back(77);
82+
v.push_back(14);
83+
v.push_back(10);
84+
v.push_back(1);
85+
v.push_back(3);
86+
v.push_back(14);
87+
v.push_back(5);
88+
v.push_back(27);
89+
90+
copy(v.begin(), v.end(), ostream_iterator<int>(cout, ", "));
91+
cout << endl;
92+
remove_copy_if(v.begin(), v.end(), back_inserter(v3), bind(equal_to<int>(), bind(modulus<int>(), _1, 7), 0));
93+
copy(v3.begin(), v3.end(), ostream_iterator<int>(cout, ", "));
94+
cout << endl;
95+
96+
return 0;
97+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#
2+
# Generated Makefile - do not edit!
3+
#
4+
# Edit the Makefile in the project folder instead (../Makefile). Each target
5+
# has a -pre and a -post target defined where you can add customized code.
6+
#
7+
# This makefile implements configuration specific macros and targets.
8+
9+
10+
# Environment
11+
MKDIR=mkdir
12+
CP=cp
13+
GREP=grep
14+
NM=nm
15+
CCADMIN=CCadmin
16+
RANLIB=ranlib
17+
CC=gcc
18+
CCC=g++
19+
CXX=g++
20+
FC=
21+
AS=as
22+
23+
# Macros
24+
CND_PLATFORM=MinGW-Windows
25+
CND_CONF=Debug
26+
CND_DISTDIR=dist
27+
28+
# Include project Makefile
29+
include Makefile
30+
31+
# Object Directory
32+
OBJECTDIR=build/${CND_CONF}/${CND_PLATFORM}
33+
34+
# Object Files
35+
OBJECTFILES= \
36+
${OBJECTDIR}/main.o
37+
38+
39+
# C Compiler Flags
40+
CFLAGS=
41+
42+
# CC Compiler Flags
43+
CCFLAGS=
44+
CXXFLAGS=
45+
46+
# Fortran Compiler Flags
47+
FFLAGS=
48+
49+
# Assembler Flags
50+
ASFLAGS=
51+
52+
# Link Libraries and Options
53+
LDLIBSOPTIONS=
54+
55+
# Build Targets
56+
.build-conf: ${BUILD_SUBPROJECTS}
57+
"${MAKE}" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/w7countoddnumbers.exe
58+
59+
dist/Debug/MinGW-Windows/w7countoddnumbers.exe: ${OBJECTFILES}
60+
${MKDIR} -p dist/Debug/MinGW-Windows
61+
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/w7countoddnumbers ${OBJECTFILES} ${LDLIBSOPTIONS}
62+
63+
${OBJECTDIR}/main.o: main.cpp
64+
${MKDIR} -p ${OBJECTDIR}
65+
${RM} $@.d
66+
$(COMPILE.cc) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cpp
67+
68+
# Subprojects
69+
.build-subprojects:
70+
71+
# Clean Targets
72+
.clean-conf: ${CLEAN_SUBPROJECTS}
73+
${RM} -r build/Debug
74+
${RM} dist/Debug/MinGW-Windows/w7countoddnumbers.exe
75+
76+
# Subprojects
77+
.clean-subprojects:
78+
79+
# Enable dependency checking
80+
.dep.inc: .depcheck-impl
81+
82+
include .dep.inc
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#
2+
# Generated Makefile - do not edit!
3+
#
4+
# Edit the Makefile in the project folder instead (../Makefile). Each target
5+
# has a -pre and a -post target defined where you can add customized code.
6+
#
7+
# This makefile implements configuration specific macros and targets.
8+
9+
10+
# Environment
11+
MKDIR=mkdir
12+
CP=cp
13+
GREP=grep
14+
NM=nm
15+
CCADMIN=CCadmin
16+
RANLIB=ranlib
17+
CC=gcc
18+
CCC=g++
19+
CXX=g++
20+
FC=
21+
AS=as
22+
23+
# Macros
24+
CND_PLATFORM=MinGW-Windows
25+
CND_CONF=Release
26+
CND_DISTDIR=dist
27+
28+
# Include project Makefile
29+
include Makefile
30+
31+
# Object Directory
32+
OBJECTDIR=build/${CND_CONF}/${CND_PLATFORM}
33+
34+
# Object Files
35+
OBJECTFILES= \
36+
${OBJECTDIR}/main.o
37+
38+
39+
# C Compiler Flags
40+
CFLAGS=
41+
42+
# CC Compiler Flags
43+
CCFLAGS=
44+
CXXFLAGS=
45+
46+
# Fortran Compiler Flags
47+
FFLAGS=
48+
49+
# Assembler Flags
50+
ASFLAGS=
51+
52+
# Link Libraries and Options
53+
LDLIBSOPTIONS=
54+
55+
# Build Targets
56+
.build-conf: ${BUILD_SUBPROJECTS}
57+
"${MAKE}" -f nbproject/Makefile-Release.mk dist/Release/MinGW-Windows/w7countoddnumbers.exe
58+
59+
dist/Release/MinGW-Windows/w7countoddnumbers.exe: ${OBJECTFILES}
60+
${MKDIR} -p dist/Release/MinGW-Windows
61+
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/w7countoddnumbers ${OBJECTFILES} ${LDLIBSOPTIONS}
62+
63+
${OBJECTDIR}/main.o: main.cpp
64+
${MKDIR} -p ${OBJECTDIR}
65+
${RM} $@.d
66+
$(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cpp
67+
68+
# Subprojects
69+
.build-subprojects:
70+
71+
# Clean Targets
72+
.clean-conf: ${CLEAN_SUBPROJECTS}
73+
${RM} -r build/Release
74+
${RM} dist/Release/MinGW-Windows/w7countoddnumbers.exe
75+
76+
# Subprojects
77+
.clean-subprojects:
78+
79+
# Enable dependency checking
80+
.dep.inc: .depcheck-impl
81+
82+
include .dep.inc

0 commit comments

Comments
 (0)