Thread: use of "for loops"

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by Dino View Post
    Sure, turn this in:

    Code:
    int i ; 
    for (i = 0 ; i < 1 ; i++) printf("1") ; 
    for (i = 0 ; i < 1 ; i++) printf("22") ; 
    for (i = 0 ; i < 1 ; i++) printf("333") ; 
    for (i = 0 ; i < 1 ; i++) printf("4444") ; 
    for (i = 0 ; i < 1 ; i++) printf("55555") ;
    Haha! That is amusing.

    Example:
    Code:
    /* Copyright (c) 2008. master5001. All rights reserved. */
    #include <vector>
    #include <iostream>
    
    int main(void)
    {
      std::vector<int> a;
      std::vector<int>::iterator begin, end;
      int i, j, k;
      
      std::cout << "Put a number! "; // no time for pleasantries in this program.
      std::cin >> j;
    
      j = +j;
    
      for(int i = 0; i < j;)
       a.push_back(++i);
    
      for(begin = a.begin(), end = a.end(); begin != end; begin++, --k)
      {
        for(i = 0; i < *begin; ++i)
          std::cout << *begin;
        std::cout << std::endl;
      }
    
      return 0;
    }
    Turn that in.
    Last edited by master5001; 10-07-2008 at 12:39 PM.

Popular pages Recent additions subscribe to a feed