Results 1 to 5 of 5

Thread: C

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    user-friendly 0wn3r's Avatar
    Join Date: Mar:2006
    Location: Bulgaria,Plovdiv
    Posts: 1,165

    C

    , ... , .
    Code:
    #include <iostream.h>
    #include <string.h>
    #include <stdio.h>
    int main ()
    {
        char str[10], *p;
        printf ("Enter string: ");
        gets (str);
        p=str;
        while (*p && *p!=' ') p++;
        printf (p);
        system ("pause");
        return 0;
    }
    , . , . , "printf (p);" , .

    :
    while(*p) { printf (*p); p++;} . , , printf (p) p. ?

  2. #2
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    - printf. , printf("%s", p);. ( ) - printf("%c", *p);.
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  3. #3
    philosophus duratea icaci's Avatar
    Join Date: Oct:2006
    Location: Aachen
    Posts: 2,698
    printf(p) , p, , printf. , (%), . ... , putchar(*p). p ( , , ), printf("%x", p).
    Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others

  4. #4
    user-friendly 0wn3r's Avatar
    Join Date: Mar:2006
    Location: Bulgaria,Plovdiv
    Posts: 1,165
    .

  5. #5
    user-friendly 0wn3r's Avatar
    Join Date: Mar:2006
    Location: Bulgaria,Plovdiv
    Posts: 1,165
    ,

    :

    unsigned a[5][5]. void fillMatrix (a[][5], unsigned n), a[][] :
    , . ., , 1-4, 5-7, 8-9, 10, (a[0][0] a[n][n] ). , , a[4][5] ( a[5][5]) 11, - 11-14, 15-17, 18-19, - 20. :

    0 20 19 17 14
    1 0 18 16 13
    2 5 0 15 12
    3 6 8 0 11
    4 7 9 10 0

    , .
    Code:
    #include <iostream.h>
    #include <iomanip.h>
    
    using namespace std;
    
    void fillMatrix(unsigned a[][5], unsigned n);
    
    unsigned int a[5][5], i, j, step = 0;
    const int n = 5;
    
    int main (void)
    {
        fillMatrix (a, n);
        
        for (i = 0; i < n; i++)
        {
             for (j = 0; j < n; j++)    
                 cout<<setw(5)<<a[i][j]; 
                 
             cout<<endl;
        }
        
        system ("pause");
        return 0;
    }
    
    void fillMatrix(unsigned a[][5], unsigned n)
    {
         
         for(i=0; i<n ; i++)
           for(j=0; j<n; j++)  a[i][j]=0; 
         
         for (j=0; j<n-1; j++)                  
           for (i=1; i<n; i++)
             {
                step++;
                a[i][j] = step;
             }
          
         step = 21;
            
         for (j=1; j<n; j++)       
           for (i=0 ; i<j ; i++)
             {
                step--;
                a[i][j] = step;
             }
    }
    Last edited by 0wn3r; 4th May 2009 at 00:04.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |