Skip to content

Instantly share code, notes, and snippets.

@c5e3
Last active November 23, 2016 00:16
Show Gist options
  • Save c5e3/80671a460a96f3269c83cbe8596ef7fb to your computer and use it in GitHub Desktop.
Save c5e3/80671a460a96f3269c83cbe8596ef7fb to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(int argc, char **argv)
{
int i=0,j=0,temp=0,mod=0,flag=0;
printf("[0] +\n[1] *\nselect operator: ");
scanf("%d", &flag);
printf("modulo value: ");
scanf("%d", &mod);
printf("\n\n\t");
for( j = 0; j < mod; j++){
printf("%d\t", j);
}
printf("\n");
for( i = 0; i < mod; i++){ // column-loop
printf("%d\t", i);
for( j = 0; j < mod; j++){ // row-loop
if( flag == 0 ){
temp = ( i + j ) % mod;
} else if( flag == 1 ){
temp = ( i * j ) % mod;
}
if( ( temp == 1 && flag == 1 ) || ( temp == 0 && flag == 0 ) ){
printf("\x1B[31m");
}
printf("%d", temp);
printf("\x1B[0m");
printf("\t");
}
printf("\n");
}
printf("\n\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment