From 68bcbf1e0e61958f737bfc279974903f1b0c2502 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 15 Oct 2016 09:32:53 +0200 Subject: Initial --- .gitignore | 3 +++ Makefile | 24 ++++++++++++++++++++++++ stddev.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 stddev.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1b6649e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +stddev +*.o +*.dSYM diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..733d520 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +CXX = g++ +CXXFLAGS = -Wall -Wextra -std=c++11 -fwrapv +ifneq ($(DEBUG),) + CXXFLAGS += -g +else + CXXFLAGS += -O2 +endif +BIN = stddev + +.PHONY: all clean remake + +all: $(BIN) + +clean: + rm -rf $(BIN) *.o *.dSYM + +remake: clean all + + +$(BIN): $(patsubst %.cpp,%.o,$(wildcard *.cpp)) + $(CXX) -o $@ $^ + +%.o: %.cpp $(wildcard *.h) + $(CXX) $(CXXFLAGS) -c -o $@ $< diff --git a/stddev.cpp b/stddev.cpp new file mode 100644 index 0000000..c804bf3 --- /dev/null +++ b/stddev.cpp @@ -0,0 +1,47 @@ +#include +#include +#include + +using namespace std; + +const char *argv0; + +void usage(){ + cerr<<"Usage: "< data; + + double total=0; + while(true){ + double v; + cin>>v; + if(!cin)break; + data.push_back(v); + total+=v; + } + if(data.size()==0){ + cerr<<"No data"<