mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 19:36:26 +02:00
[CCV] Added three test programs for CCV exercise 1
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
25
ccv/sheet1/AskInteger.cpp
Normal file
25
ccv/sheet1/AskInteger.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by jim on 4/4/17.
|
||||
//
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int input;
|
||||
cout << "Bitte geben Sie eine Zahl ein." << endl;
|
||||
cin >> input;
|
||||
if (input > 9)
|
||||
{
|
||||
cout << input << " ist größer gleich 10." << endl;
|
||||
}
|
||||
else if (input >= 0)
|
||||
{
|
||||
cout << input << " liegt zwischen einschließlich 0 und 9." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << input << " ist negativ." << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
30
ccv/sheet1/Rectangle.cpp
Normal file
30
ccv/sheet1/Rectangle.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Created by jim on 4/4/17.
|
||||
//
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Rectangle
|
||||
{
|
||||
private:
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
|
||||
public:
|
||||
Rectangle(unsigned int width, unsigned int height)
|
||||
{
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
unsigned int area()
|
||||
{
|
||||
return this->height * this->width;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Rectangle* rec = new Rectangle(10, 20);
|
||||
cout << rec->area() << endl;
|
||||
}
|
||||
12
ccv/sheet1/hello.cpp
Normal file
12
ccv/sheet1/hello.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
//
|
||||
// Created by jim on 4/4/17.
|
||||
//
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello world!";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user