Format
There really is no hope of making this code even half-way decent without spending the time to rewrite them all properly. Don't want to do any of that
This commit is contained in:
12
C/Addierer.c
12
C/Addierer.c
@@ -1,10 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int summe = 0;
|
||||
for(int i=0; i<5; i++) {
|
||||
printf("Gib die Zahl ein:")
|
||||
for ( int i = 0; i < 5; i++ ) {
|
||||
printf( "Gib die Zahl ein:" );
|
||||
int zahl;
|
||||
scanf("%d", &zahl);
|
||||
scanf( "%d", &zahl );
|
||||
summe = summe + zahl;
|
||||
}
|
||||
printf("Summe: %d\n", summe);
|
||||
}
|
||||
printf( "Summe: %d\n", summe );
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
|
||||
int main() {
|
||||
vector<string> msg { "Hello", "C++", "World", "from", "VS Code", "and the C++ extension!" };
|
||||
|
||||
for (const string& word : msg)
|
||||
{
|
||||
for ( const string &word : msg )
|
||||
cout << word << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
// Deklaration der Variablen
|
||||
int hist[26] = {};
|
||||
int hist[ 26 ] = {};
|
||||
int i, k, c, count;
|
||||
int num = 0;
|
||||
|
||||
|
||||
// Zeichen bis EOF einlesen (nur a-z werden berücksichtigt)
|
||||
// EOF wird im Terminal mit CTRL-D eingegeben!
|
||||
while ((c = getchar()) != EOF) {
|
||||
if ((c>96) && (c<123)) {
|
||||
while ( ( c = getchar() ) != EOF ) {
|
||||
if ( ( c > 96 ) && ( c < 123 ) ) {
|
||||
// Zähler für diesen Buchstaben erhöhen
|
||||
hist[c-97]++;
|
||||
hist[ c - 97 ]++;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
// Histogramm ausgeben
|
||||
printf("\n");
|
||||
for (i=0; i<26; i++) {
|
||||
count = hist[i];
|
||||
if (count > 0) {
|
||||
printf("%c : %f\n",i+97, (count/(float)num)*100);
|
||||
}
|
||||
|
||||
// Histogramm ausgeben
|
||||
printf( "\n" );
|
||||
for ( i = 0; i < 26; i++ ) {
|
||||
count = hist[ i ];
|
||||
if ( count > 0 )
|
||||
printf( "%c : %f\n", i + 97, ( count / (float) num ) * 100 );
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
// Deklaration der Variablen
|
||||
int hist[26] = {};
|
||||
int hist[ 26 ] = {};
|
||||
int i, k, c, count;
|
||||
|
||||
|
||||
// Zeichen bis EOF einlesen (nur a-z werden berücksichtigt)
|
||||
// EOF wird im Terminal mit CTRL-D eingegeben!
|
||||
while ((c = getchar()) != EOF) {
|
||||
if ((c>96) && (c<123)) {
|
||||
while ( ( c = getchar() ) != EOF ) {
|
||||
if ( ( c > 96 ) && ( c < 123 ) ) {
|
||||
// Zähler für diesen Buchstaben erhöhen
|
||||
hist[c-97]++;
|
||||
hist[ c - 97 ]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Histogramm ausgeben
|
||||
printf("\n");
|
||||
for (i=0; i<26; i++) {
|
||||
count = hist[i];
|
||||
if (count > 0) {
|
||||
printf("%c : ",i+97);
|
||||
for (k=0; k<count; k++)
|
||||
printf("*");
|
||||
printf("\n");
|
||||
|
||||
// Histogramm ausgeben
|
||||
printf( "\n" );
|
||||
for ( i = 0; i < 26; i++ ) {
|
||||
count = hist[ i ];
|
||||
if ( count > 0 ) {
|
||||
printf( "%c : ", i + 97 );
|
||||
for ( k = 0; k < count; k++ )
|
||||
printf( "*" );
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user