Esempio n. 1
0
// Ausgeben Tabelle
void tabelleAusgeben(const int von, const int bis, const int schritt)
{
	int i;

	printf("     i    i^2      i^3    Wurzel(i)   ln(i)                  e^i\n");
	
	strich(70,'-');

	for(i = von; i <= bis; i = i + schritt)
	{
		float ifl = (float)i;

		printf("%6.f %6.f %8.f %11f %11f %22f  \n",
		ifl, ifl * ifl, pow(ifl,3), sqrt(ifl), log(ifl), exp(ifl));
	}

	strich(70,'-');
}
Esempio n. 2
0
int main() // Beginn Hauptprogramm          **************************
{
	//************************ Vereinbarungsteil **************************
	int von, bis, schritt;

	//************************ Anweisungsteil  ****************************
	// Dialoger?ffnung 
	strich(50,'-');
	printf ("Zahltab: Berechnung von Zahlentafeln\n");
	strich(50,'-');

	//grenzenEinlesen(&von, &bis);
	von = untereGrenzeEinlesen();
	bis = obereGrenzeEinlesen(von);

	// Einlesen Schrittweite
	printf ("Bitte Schrittweite eingeben: ");
	scanf ("%d",&schritt);

	tabelleAusgeben(von, bis, schritt);

	printf("Servus! \n");
	return(0);
} //***************** Ende Hauptprogramm ***************************
Esempio n. 3
0
static void showpartner()
{
  register int   i, k;
  register char *p, *p1;
  auto	   int	 firsttime[2][2];


  memset(firsttime, 0, sizeof(firsttime));

  for (k = 0; k < 2; k++) {
    if (((k == 0) && showincoming) || ((k == 1) && showoutgoing)) {

      for (i = 0; i < knowns; i++)
        if (partner[k][i].ncalls) {
          if (k) {

            if (!firsttime[k][0]) {
	      printf("\nAngerufene (dialout)      calls   Charge        Duration       Computed\n");
              strich('-', 71);
              firsttime[k][0] = 1;
            } /* if */

            printf("%-25s %5d   %12s %s   %12s\n",
              clip(onlynumbers ? partner[k][i].num : known[i]->who, 25),
              partner[k][i].ncalls,
              printRate(partner[k][i].pay),
              timestr(partner[k][i].duration),
              printRate(partner[k][i].compute));
          }
          else {

            if (!firsttime[k][0]) {
              printf("\nAnrufer (dialin)          calls  Duration\n");
              strich('-', 41);
              firsttime[k][0] = 1;
            } /* if */

            printf("%-25s %5d %s\n",
              clip(onlynumbers ? partner[k][i].num : known[i]->who, 25),
              partner[k][i].ncalls,
              timestr(partner[k][i].duration));
          } /* else */
        } /* if */

      printf("\n");

      for (i = 0; i < nunknown[k]; i++)
        if (unknown[k][i].ncalls) {
          p = beautify(unknown[k][i].num);

          if (k) {

            if (!firsttime[k][1]) {
	      printf("\nunbekannte Angerufene (dialout)     von          calls   Charge         Duration       Computed\n");
              strich('-', 95);
              firsttime[k][1] = 1;
            } /* if */

            p1 = msnsum[SUBTOTAL][unknown[k][i].si1][unknown[k][i].ihome].alias;

            printf("%-16s <- %-12s %5d   %12s  %s   %12s\n",
              p,
              clip(p1 ? p1 : "", 16),
              unknown[k][i].ncalls,
              printRate(unknown[k][i].pay),
              timestr(unknown[k][i].duration),
              printRate(unknown[k][i].compute));
          }
          else {

            if (!firsttime[k][1]) {
	      printf("\nunbekannte Anrufer (dialin)         an Rufnummer calls  Duration\n");
              strich('-', 64);
              firsttime[k][1] = 1;
            } /* if */

            printf("%-16s -> %-12s %5d %s\n",
              p,
              msnsum[SUBTOTAL][unknown[k][i].si1][unknown[k][i].ihome].alias,
              unknown[k][i].ncalls,
              timestr(unknown[k][i].duration));
          } /* else */
        } /* if */
      } /* if */
  } /* for */
} /* showpartner */
Esempio n. 4
0
static void total(int w)
{
  register int i, j, firsttime = 1;
  auto     int ncalls = 0, failed = 0;
  auto     double duration = 0.0, pay = 0.0, compute = 0.0, aktiv = 0.0;


  firsttime = 1;

  for (i = 0; i < nhome; i++) {
    for (j = 0; j < MAXSI; j++) {
      if (msnsum[w][j][i].ncalls) {

        if (firsttime) {
          firsttime = 0;

  	  printf("\n\nMSN                   calls  Duration         Charge       Computed\n");
  	  strich('-', 67);
        }

        printf("%6s,%d %-12s %5d %s  %13s",
          msnsum[w][j][i].msn,
          j,
          msnsum[w][j][i].alias ? msnsum[w][j][i].alias : "",
          msnsum[w][j][i].ncalls,
          timestr(msnsum[w][j][i].duration),
	  printRate(msnsum[w][j][i].pay));

        if (msnsum[w][j][i].pay == msnsum[w][j][i].compute)
          printf("\n");
        else
          printf("  %13s\n", printRate(msnsum[w][j][i].compute));

        ncalls   += msnsum[w][j][i].ncalls;
        duration += msnsum[w][j][i].duration;
        pay      += msnsum[w][j][i].pay;
        compute  += msnsum[w][j][i].compute;
      } /* if */

      if (w == SUBTOTAL) {
        strcpy(msnsum[TOTAL][j][i].msn, msnsum[SUBTOTAL][j][i].msn);
        msnsum[TOTAL][j][i].alias = msnsum[SUBTOTAL][j][i].alias;
        msnsum[TOTAL][j][i].ncalls   += msnsum[SUBTOTAL][j][i].ncalls;
        msnsum[TOTAL][j][i].duration += msnsum[SUBTOTAL][j][i].duration;
        msnsum[TOTAL][j][i].pay      += msnsum[SUBTOTAL][j][i].pay;
        msnsum[TOTAL][j][i].compute  += msnsum[SUBTOTAL][j][i].compute;

        msnsum[SUBTOTAL][j][i].ncalls = 0;
        msnsum[SUBTOTAL][j][i].duration = 0;
        msnsum[SUBTOTAL][j][i].pay = 0;
        msnsum[SUBTOTAL][j][i].compute = 0;
      } /* if */
    } /* for */
  } /* for */

  if (!firsttime) {
  strich('=', 67);

  printf("                      %5d %s  %13s",
    ncalls,
    timestr(duration),
    printRate(pay));

  if (pay == compute)
    printf("\n");
  else
    printf("  %13s\n", printRate(compute));
  } /* if */

  ncalls = 0;
  failed = 0;
  duration = 0.0;
  pay = 0.0;
  compute = 0.0;

  firsttime = 1;


  for (i = 0; i < MAXPROVIDER; i++) {
    if (provsum[w][i].ncalls) {
      if (firsttime) {
        firsttime = 0;

  	printf("\n\nProvider                        calls  Duration         Charge       Computed failures  avail\n");
  	strich('-', 93);
      } /* if */

      if (i < 100)
        printf("  010%02d", i);
      else if (i < 200)
        printf("0100%03d", i - 100);
      else
        printf("01900%02d", i - 200);

      printf(":%-24s", getProvider(pnum2prefix(i, c.connect)));

      printf("%5d %s  %13s  %13s %8d %5.1f%%\n",
        provsum[w][i].ncalls,
        timestr(provsum[w][i].duration),
        printRate(provsum[w][i].pay),
        printRate(provsum[w][i].compute),
        provsum[w][i].failed,
        100.0 * (provsum[w][i].ncalls - provsum[w][i].failed) / provsum[w][i].ncalls);

      ncalls   += provsum[w][i].ncalls;
      duration += provsum[w][i].duration;
      pay      += provsum[w][i].pay;
      compute  += provsum[w][i].compute;
      failed   += provsum[w][i].failed;

      if (w == SUBTOTAL) {
        provsum[TOTAL][i].ncalls   += provsum[SUBTOTAL][i].ncalls;
        provsum[TOTAL][i].duration += provsum[SUBTOTAL][i].duration;
        provsum[TOTAL][i].pay      += provsum[SUBTOTAL][i].pay;
        provsum[TOTAL][i].failed   += provsum[SUBTOTAL][i].failed;
        provsum[TOTAL][i].compute  += provsum[SUBTOTAL][i].compute;

        provsum[SUBTOTAL][i].ncalls = 0;
        provsum[SUBTOTAL][i].duration = 0;
        provsum[SUBTOTAL][i].pay = 0;
        provsum[SUBTOTAL][i].failed = 0;
        provsum[SUBTOTAL][i].compute = 0;
      } /* if */
    } /* if */
  } /* for */

  if (!firsttime) {
  strich('=', 93);

  printf("%*s%5d %s  %13s  %13s %8d %5.1f%%\n",
    32, "",
    ncalls,
    timestr(duration),
    printRate(pay),
    printRate(compute),
    failed,
    100.0 * (ncalls - failed) / ncalls);
  } /* if */


  ncalls = 0;
  duration = 0.0;
  pay = 0.0;
  compute = 0.0;
  aktiv = 0;

  firsttime = 1;


  for (i = 0; i < MAXZONE; i++) {
    if (zonesum[w][i].ncalls) {

      if (firsttime) {
        firsttime = 0;

  			printf("\n\nZone            calls  Duration         Charge       Computed");

  			if (0 /* preselect == DTAG */) {
    		  printf("     AktivPlus\n");
    			strich('-', 73);
  			}
  			else {
    		  printf("\n");
    			strich('-', 61);
  			} /* else */
      } /* if */

      switch (i) {
        case 0 : printf("FreeCall        "); break;
        case 1 : printf("Ortszone        "); break;
        case 2 : printf("CityCall (R20)  "); break;
        case 3 : printf("RegioCall (R50) "); break;
        case 4 : printf("GermanCall      "); break;
        case 5 : printf("Sonderrufnummern"); break;
        case 6 : printf("Ausland         "); break;
        case 7 : printf("elsewhere       "); break;
      } /* switch */

      printf("%5d %s  %13s  %13s",
        zonesum[w][i].ncalls,
        timestr(zonesum[w][i].duration),
        printRate(zonesum[w][i].pay),
        printRate(zonesum[w][i].compute));

      if (0 /* preselect == DTAG */)
        printf("  %13s\n", printRate(zonesum[w][i].aktiv));
      else
        printf("\n");

      ncalls   += zonesum[w][i].ncalls;
      duration += zonesum[w][i].duration;
      pay      += zonesum[w][i].pay;
      compute  += zonesum[w][i].compute;
      aktiv    += zonesum[w][i].aktiv;
    } /* if */

    if (w == SUBTOTAL) {
      zonesum[TOTAL][i].ncalls   += zonesum[SUBTOTAL][i].ncalls;
      zonesum[TOTAL][i].duration += zonesum[SUBTOTAL][i].duration;
      zonesum[TOTAL][i].pay      += zonesum[SUBTOTAL][i].pay;
      zonesum[TOTAL][i].compute  += zonesum[SUBTOTAL][i].compute;
      zonesum[TOTAL][i].aktiv    += zonesum[SUBTOTAL][i].aktiv;

      zonesum[SUBTOTAL][i].ncalls = 0;
      zonesum[SUBTOTAL][i].duration = 0;
      zonesum[SUBTOTAL][i].pay = 0;
      zonesum[SUBTOTAL][i].compute = 0;
      zonesum[SUBTOTAL][i].aktiv = 0;
    } /* if */
  } /* for */

  if (!firsttime) {
  strich('=', (0 /* preselect == DTAG */) ? 73 : 61);

  printf("%*s%5d %s  %13s  %13s",
    16, "",
    ncalls,
    timestr(duration),
    printRate(pay),
    printRate(compute));

  if (0 /* preselect == DTAG */)
    printf("  %13s\n", printRate(aktiv));
  else
    printf("\n");

  printf("\n\n");
  } /* if */
} /* total */
Esempio n. 5
0
File: inf1.c Progetto: cebor/prog1
void dialog(char *Ueberschrift) // gibt Überschrift aus 
{
	strich (50, '-'); // Aufruf der eben definierten Funktion
	printf("%s \n", Ueberschrift);
	strich (50, '-');
}
Esempio n. 6
0
void dreieck(void)
{
	double a;  // Seitenlänge von Seite a
	double alpha_deg;  // Winkel in Grad
	double b;
	double beta_deg;
	double c;
	double gamma_deg = 90;

	int a_floor, b_floor, c_floor;
	int a_ceil, b_ceil, c_ceil;
	int a_round, b_round, c_round;

	// Error Var
	int err;

	// Dialogeröffnung 
	strich(50,'-');
	printf ("Rechtwinkliges Dreieck\n");
	strich(50,'-');

	// Seite/Winkel einlesen
	do
	{
		int i = 0;
		char side[100];

		printf("Bitte Laenge Seite a eingeben: ");

		// scanf("%lf", &a);

		fgets(side, 100, stdin);

		// check for alpha
		err = 0;
		while (side[i] != '\0') {
			if (isalpha(side[i])) err = 1;
			i += 1;
		}

		a = strtod(side, NULL);

		if (err == 1)
			printf("No Chars !!!\n");
		else if (a <= 0)
			printf("Beachte: a > 0 !!!\n");
	} while (err == 1 || a <= 0);

	do
	{
		int i = 0;
		char angel[100];

		printf("Bitte Winkel Alpha in Grad eingeben: ");

		// scanf("%lf", &alpha_deg);

		fgets(angel, 100, stdin);

		// check for alpha
		err = 0;
		while (angel[i] != '\0') {
			if (isalpha(angel[i])) err = 1;
			i += 1;
		}

		alpha_deg = strtod(angel, NULL);

		if (err == 1)
			printf("No Chars !!!\n");
		else if (alpha_deg >= 90 || alpha_deg <= 0)
			printf("Beachte: 0 < Winkel < 90 !!!\n");
	} while (err == 1 || alpha_deg >= 90 || alpha_deg <= 0);

	// Berechnung aller Seiten und Winkel
	b = a / tan(deg2rad(alpha_deg));
	c = a / sin(deg2rad(alpha_deg));

	beta_deg = 90 - alpha_deg;


	// speichern aller Ergebnisse in einer neuen Variablen

	// abrunden aller Seiten auf die nächste ganze Zahl
	a_floor = floor(a);
	b_floor = floor(b);
	c_floor = floor(c);

	// aufrunden aller Seiten auf die nächste ganze Zahl
	a_ceil = ceil(a);
	b_ceil = ceil(b);
	c_ceil = ceil(c);

	// (korrektes) runden aller Seiten auf die nächste ganze Zahl
	a_round = round2(a);
	b_round = round2(b);
	c_round = round2(c);

	// Ausgabe aller Seiten und Winkel
	printf("       2 NK-Stellen   gerundet   abgerundet   aufgerundet\n");
	
	strich(57,'-');

	printf("a        %10.2f %10d   %10d    %10d\n", a, a_round, a_floor, a_ceil);
	printf("b        %10.2f %10d   %10d    %10d\n", b, b_round, b_floor, b_ceil);
	printf("c        %10.2f %10d   %10d    %10d\n", c, c_round, c_floor, c_ceil);

	printf("Alpha (Grad) %6.2f\n", alpha_deg);
	printf("Beta  (Grad) %6.2f\n", beta_deg);
	printf("Gamma (Grad) %6.2f\n", gamma_deg);
	
	printf("Alpha (rad) %7.3f\n", deg2rad(alpha_deg));
	printf("Beta  (rad) %7.3f\n", deg2rad(beta_deg));
	printf("Gamma (rad) %7.3f\n", deg2rad(gamma_deg));
}