my code stock.com

opis1
opis2

Snippet options

Download: Download snippet as program12.c.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>
#define SIZE 50

void splitNumOnDigits(int input[],int output[][5]);
void joinDigitsOnNum(int input[][5],int output[]);
void drawNum(int output[]);
void main()
{
    int arr1[SIZE],arr2[SIZE][5],s1,i,j;
    drawNum(arr1);
    for(i=0;i<SIZE;i++)
        printf("%d\n",arr1[i]);
    splitNumOnDigits(arr1,arr2);
    printf("\n");
    for(i=0;i<SIZE;i++){
        for(j=0;j<5;j++)
            printf("%d ",arr2[i][j]);
        printf("\n");
    }
    printf("\n");
    joinDigitsOnNum(arr2,arr1);
    for(i=0;i<SIZE;i++)
        printf("%d\n",arr1[i]);
}
void joinDigitsOnNum(int input[][5],int output[])
{
    int i,j;
    float aux;
    for(i=0;i<SIZE;i++){
        output[i]=0;
        for(j=0;j<5;j++){
            aux = input[i][j]*pow(10,j);
            output[i]+=aux;
        }
        j=0;
    }
}
void splitNumOnDigits(int input[],int output[][5])
{
    int i,j,aux;
    for(i=0;i<SIZE;i++){
        for(j=0;j<5;j++){
            aux=input[i];
            input[i]-=aux;
            output[i][j]=aux;
            input[i]=input[i]/10;
        }
        j=0;
    }
}
void drawNum(int output[])
{
    int i;
    srand(time(NULL));
    for(i=0;i<SIZE;i++)
        output[i]=rand()%50000;
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.