47 lines
1.6 KiB
C
47 lines
1.6 KiB
C
#include <stdio.h>
|
|
#include <malloc.h>
|
|
#include "PointersLibs.h"
|
|
|
|
void InsertNumberToRowInMat(int *ptr_mat, unsigned short mat_col, unsigned short custom_row, int number)
|
|
{
|
|
ptr_mat = ptr_mat + (custom_row * (mat_col));
|
|
while (mat_col)
|
|
{
|
|
*(ptr_mat + mat_col--) = number % TEN;
|
|
number /= TEN;
|
|
}
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// exe 3
|
|
// -----
|
|
//
|
|
// General : The program takes the last digits according to input
|
|
// from each number inputted.
|
|
//
|
|
// Input : how many numbers to take and input, and how many digits
|
|
// at least for the input.
|
|
//
|
|
// Process : the program gets input from user, then takes the
|
|
// last numbers according to input, and makes a char
|
|
// matrix out of it.
|
|
//
|
|
// Output : numbers in a matrix looking form.
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Proggramer : Cohen Idan
|
|
// Student No : 211675038
|
|
// Date : 21.11.19
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
unsigned short HowManyNums = 4,
|
|
HowManyDigits = 3;
|
|
int *mat = malloc(sizeof(int) * HowManyNums * HowManyDigits);
|
|
|
|
InsertNumberToRowInMat(mat, HowManyDigits, 0, 167367);
|
|
InsertNumberToRowInMat(mat, HowManyDigits, 1, 6376);
|
|
InsertNumberToRowInMat(mat, HowManyDigits, 2, 2462172);
|
|
InsertNumberToRowInMat(mat, HowManyDigits, 3, 64036);
|
|
free(mat);
|
|
} |