Jump to content


Check out our Community Blogs

Kintamasis

Member Since 08 Mar 2011
Offline Last Active Dec 06 2011 10:48 AM
-----

Topics I've Started

For loop for creating folders from file

06 December 2011 - 05:08 AM

Hello, I'm new in bash scripting and i need some help with for loop script. I have file name - YER and in this file are 4 words as,sd,df,fg . I need to create
a for loop that take information from YER file and create 4 folders(as,sd,df,fg). can some one help me ?

need some help with array !

05 June 2011 - 07:24 AM

Hello i need help, i need to sum all array in vector. first array first element with second array first element and third array first element and so on... And i have one problem, the 2 first elements are incorrect always 3584562455 very big, and the seconds numbers are correct. So where is a problem ? please help....

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{ int n, i, *ptr, *agg, *arr, *naujas;

   time_t seconds;
   time (&seconds);
   srand((unsigned int)seconds);

    printf("array N elements");
    scanf("%d", &n);
    printf("\n");

 ptr = (int*) malloc(n*sizeof(int) ); 
 agg = (int*) malloc(n*sizeof(int) );
 arr = (int*) malloc(n*sizeof(int) );
 naujas = (int*) malloc(n*sizeof(int) );

    if ((ptr == NULL) || (agg == NULL) || (arr == NULL)) 
        {
        printf ("no memory\n");
        return 1;
        }

        for (i=0; i<n; i++)  
        {
            ptr[i] = rand();
            agg[i] = rand();
            arr[i] = rand();
        }
        for (i=0; i<n; i++)
        {
            printf( "%d ptr element = %d\n", i, ptr[i] ); 
        }
        free (ptr);
        printf("\n");
        for (i=0; i<n; i++)
        {
            printf("%d agg element = %d\n", i , agg[i]);
        }
        free (agg);
        printf("\n");
        for (i=0; i<n; i++)
        {
            printf("%d arr element = %d\n", i , arr[i]); 
        }
        free (arr);
        printf("\n");

        for(i=0; i<n; i++)    // this is a problem
        {
            naujas=0;
            naujas = ptr[i]+agg[i]+arr[i];  
            printf("fourth vector %d element = %d\n", i, naujas);
        }

   return 0;
}

Need to change code from C++ into C HELP !

09 May 2011 - 08:40 AM

hello, i need your help, i have code but dont know how to change it to c language, please help me.

#include <iostream>

    using namespace std;

    //function to calculate factorial

    int dfact(int n)

    {
           int i;
           double res=1.0;

           for(i=n;i>=1;i-=2)
           {
           res *=i;
           }

           return res;
    }

    int main( )
    {    int n;

     cout << "Enter the number=";

      cin >> n; // Take the number as an input
      cout << n << "! = " <<dfact(n) << endl; // output

      return 0;
    }

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download