Results 1 to 17 of 17

Thread: -

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Jun:2010
    Location:
    Posts: 171

    -

    , , , , .
    .


    Code:
    #include <stdio.h>
    int main(void)
    {
        int height,rows,empty,k=0,i,a,m=1,s,h=2;
        printf("Enter odd number: ");
        scanf("%d",&height);
        
        for(rows=1;rows<=(height/2+1);rows++)
        {
            for(empty=1;empty<=(height/2+1)-rows;empty++)
            {
               printf(" ");
            } 
              for( i=1;i<=rows+k;i++ )
              {
                printf("*");
                
              }                     
                    k++;   
            printf("\n");
          }
         for(rows=1;rows<=height/2;rows++)
        {                               
              for(a=1;a<=m;a++)
            {
               printf(" ");
            }                            
             m++;
            for(s=1;s<=height-h;s++)
            {
                printf("*");                     
            }   
            h+=2;                          
          printf("\n");                                 
        }
        getch();
    }

  2. #2
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366

    - empty, i, a s
    -

  3. #3
    Registered User
    Join Date: Jun:2010
    Location:
    Posts: 171
    , .

  4. #4
    Game programmer
    Join Date: Feb:2007
    Location:
    Posts: 1,948
    Quote Originally Posted by lludmill View Post
    , .
    :
    Code:
    void print_chars(char symbol, unsigned times) {
      /*    ,  
       *  symbol, times   
       */
    }
    - ( , 50 ), -.

    , - ( , , m, p, q .. , - c count, i - iterator, s - size ., ) , . , for , , :
    Code:
      for (int iterator = 0; iterator < MAX; iterator++) {...}
    , , ..
    Last edited by Todor032; 13th August 2010 at 14:18.

  5. #5
    Registered User
    Join Date: Jun:2010
    Location:
    Posts: 171
    , , nested loop. .

  6. #6
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366
    nested loops.

    (, rows), . (, ' ' '*'), .

  7. #7
    Registered User
    Join Date: Oct:2003
    Location:
    Posts: 4,317
    , , , .
    . , , , . , .

  8. #8
    Registered User mitkohr's Avatar
    Join Date: Jul:2001
    Posts: 1,361
    , ( ++, ):
    - -
    -
    - . !
    Code:
    #include <string.h>
    #include <stdlib.h>
    #include <stdio.h>
    
    using namespace std;
    
    int main(int argc, char *argv[]) {
        
        char *line = NULL;
        int length = 0;
        int start, end;
        
        do {
            printf("Enter odd number:");
            scanf("%d", &length);
        } while(length % 2 == 0);
    
        line = (char*)malloc((length + 1)*sizeof(char));
            line[length] = 0;
        memset(line, (int)' ' & 0x00FF, length*sizeof(char));   
        start = end = length / 2;
        for(int i = 0; i < length; i++) {
                if(i < length/2 + 1) {
                     line[start--] = line[end++] = '*';
                } else {
                     line[++start] = line[--end] = ' ';
                }
                printf("|%s|\n", line);
        }
        free(line);
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    :
    Code:
    void print_chars(char symbol, unsigned times) {
      /*    ,  
       *  symbol, times   
       */
    }
    
    int main(int argc, char *argv[]) {
    
    ....
    for(int i = 0; i < 10; i++) {
    ...
     print_chars('*', i);
    }
    ....
    }
    Last edited by mitkohr; 16th August 2010 at 10:01.
    Gigabyte X570 Aorus Elite, AMD Ryzen 7 5800X@PBO+200, Noctua NH-D15, 2x16GB G.Skill F4-3600C17D-32GTZR, Palit GeForce RTX 4070 Ti GameRock Classic, 2x Sandisk Extreme II 240GB (not in RAID)+WD 320GB AAKS + WD40EZRZ + Toshiba X300 6GB, Cooler Master HAF 922, CORSAIR 750W CX

  9. #9
    Registered User
    Join Date: Oct:2003
    Location:
    Posts: 4,317
    Quote Originally Posted by mitkohr View Post
    ........
    ......
    !
    ...........
    , ? length , , , printf()?
    ,

  10. #10
    Registered User
    Join Date: Jun:2010
    Location:
    Posts: 171
    mitkohr

  11. #11
    Registered User mitkohr's Avatar
    Join Date: Jul:2001
    Posts: 1,361
    bsb (10 ) - (Java- ).
    - ():
    Code:
        line = (char*)malloc(length*sizeof(char) + 1);
        line[length] = 0;
    Gigabyte X570 Aorus Elite, AMD Ryzen 7 5800X@PBO+200, Noctua NH-D15, 2x16GB G.Skill F4-3600C17D-32GTZR, Palit GeForce RTX 4070 Ti GameRock Classic, 2x Sandisk Extreme II 240GB (not in RAID)+WD 320GB AAKS + WD40EZRZ + Toshiba X300 6GB, Cooler Master HAF 922, CORSAIR 750W CX

  12. #12
    Bombera's Avatar
    Join Date: Jul:2001
    Location: 4EVA
    Posts: 13,833
    Code:
        line = (char *)malloc((length + 1) * sizeof(char));
        line[length] = '\0';
    EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
    Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|

  13. #13
    Mire-x
    Join Date: Apr:2005
    Location: Sofia
    Posts: 763
    Quote Originally Posted by Bombera View Post
    sizeof(char)...
    NULL character ? Wikipedia : "...Other source code sequences that often work are \000, \x00, the Unicode representation \u0000, or \z...", - Unicode null 2 ? , Unicode - ...
    ...
    (10b) || !(10b)

  14. #14
    Undead user Oldman's Avatar
    Join Date: Oct:2003
    Location: outside
    Posts: 432
    Quote Originally Posted by Tarvin View Post
    ..., Unicode - ...
    ...
    Unicode . UTF-16 ( 4) . UTF-32 4 . UTF-8 , 1 4 , .
    Last edited by Oldman; 16th August 2010 at 08:17.
    .

  15. #15
    Mire-x
    Join Date: Apr:2005
    Location: Sofia
    Posts: 763
    Quote Originally Posted by Oldman View Post
    ...
    .
    (10b) || !(10b)

  16. #16
    Registered User
    Join Date: Dec:2007
    Location:
    Posts: 655
    Quote Originally Posted by Tarvin View Post
    NULL character ?
    '\0' ( L'\0' ((wchar_t) '\0')) "" ( "" "C" , , .. 8 ), . sizeof(char) , sizeof(char) == 1. , , , - , line ( "Unicode", ). :
    Code:
    line = malloc((length + 1) * sizeof(*line));
    NULL , char.

  17. #17
    Registered User mitkohr's Avatar
    Join Date: Jul:2001
    Posts: 1,361
    Quote Originally Posted by Bombera View Post
    Code:
        line = (char *)malloc((length + 1) * sizeof(char));
        line[length] = '\0';
    Java- .
    - lludmill - .
    Gigabyte X570 Aorus Elite, AMD Ryzen 7 5800X@PBO+200, Noctua NH-D15, 2x16GB G.Skill F4-3600C17D-32GTZR, Palit GeForce RTX 4070 Ti GameRock Classic, 2x Sandisk Extreme II 240GB (not in RAID)+WD 320GB AAKS + WD40EZRZ + Toshiba X300 6GB, Cooler Master HAF 922, CORSAIR 750W CX

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 |