Advertisement
meesyice

13 v2.1

Sep 22nd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main(){
  6.  
  7.  int columns;
  8.  int rows;
  9.  int rowcount , columcount;
  10.  int x , k , y , z;
  11.  k = 3;
  12.  z = 3;
  13.  /*this creates the input screen*/
  14.  printf("\t\t\t\t\tMultiplikationstabelle\n\n");
  15.  printf("Geben Sie die gewuenschte Anzahl von Reihen und Spalten ein:\n");
  16.  
  17.  printf("Spalten:(2-13)");
  18.  scanf("%d",&columcount);
  19.  
  20.  printf("Reihen(1-769):");
  21.  scanf("%d",&rowcount);
  22.  /*this checks that the input is within the parameters*/
  23.  if(columcount>13){
  24.     columcount=13;
  25.     printf("Spalten konnten nicht mehr als 2 sein\n");
  26.     y = 14;
  27.  }else{
  28.      if(columcount<2){
  29.         columcount=2;
  30.         printf("Spalten konnten nicht weniger als 2 sein\n");
  31.         y = 3;
  32.      }else{
  33.          columcount=columcount;
  34.          y = columcount + 1;
  35.      }
  36.  }
  37.  if(rowcount>769){
  38.     rowcount=769;
  39.     printf("Reihen konnten nicht mehr als 769 sein\n");
  40.  }else{
  41.      if(rowcount<1){
  42.         rowcount=1;
  43.         printf("Reihen Konnten nicht weniger als 1 sein\n");
  44.      }else{
  45.          rowcount=rowcount;
  46.      }
  47.  }
  48.  /*this creates the header*/
  49.  printf("             1     2");
  50.  while(k<y){
  51.     if(k>=10)
  52.        break;
  53.     printf("       %d",k);
  54.     k++;
  55.  }
  56.  while(k<y){
  57.     printf("      %d",k);
  58.     k++;
  59.  }
  60. printf("\n        ------------");
  61.  while(z<y){
  62.     printf("--------");
  63.     z++;
  64. }
  65. z = 1;
  66. printf("------\n");
  67. /*this creates the table*/
  68.  for(rows=1; rows <= rowcount; rows++){
  69.   printf("%d. \t[ ", rows);
  70.   for(columns=1; columns <= columcount; columns++){
  71.    x=rows*columns;
  72.    if(x<10){
  73.     printf("   %d \t", x);
  74.     }else{
  75.        if(x<100){
  76.         printf("  %d \t", x);
  77.        }else{
  78.            if(x<1000){
  79.        printf(" %d \t", x);
  80.        }else{
  81.            printf("%d \t", x);
  82.            }
  83.        }
  84.  
  85.    }
  86.   }
  87.   printf(" ]\n");
  88.  }
  89.  /*This Creates the Footer*/
  90.  printf("        --");
  91.  while(z<y){
  92.     printf("--------");
  93.     z++;
  94. }
  95. printf("\n");
  96.  
  97.  return z;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement