IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » a The latest public a snipts.

showing 1-12 of 12 snipts for a
  • Codeforces
          #include <iostream>
          #include <cmath>
           using namespace std;
           long long f(long long k,long long t)
             {
               if(k%t==0)
                return k/t;
               else
                return (int)(fabs(k/t)+1);
             }
            int main()
              {
                 long long n,m,a,y;
                 cin>>n>>m>>a;
                 y=f(n,a)*f(m,a);
                 cout<<y;;
                 return 0;
              } 
    

    copy | embed

    0 comments - tagged in  posted by IMO on Aug 18, 2010 at 7:04 a.m. EDT
  • An exec <filename command redirects stdin to a file
    19.1. Using exec
    
    An exec <filename command redirects stdin to a file. From that point on, all stdin comes from that file, rather than its normal source (usually keyboard input). This provides a method of reading a file line by line and possibly parsing each line of input using sed and/or awk.
    
    Example 19-1. Redirecting stdin using exec
    
    #!/bin/bash
    # Redirecting stdin using 'exec'.
    
    
    exec 6<&0          # Link file descriptor #6 with stdin.
                       # Saves stdin.
    
    exec < data-file   # stdin replaced by file "data-file"
    
    read a1            # Reads first line of file "data-file".
    read a2            # Reads second line of file "data-file."
    
    echo
    echo "Following lines read from file."
    echo "-------------------------------"
    echo $a1
    echo $a2
    
    echo; echo; echo
    
    exec 0<&6 6<&-
    #  Now restore stdin from fd #6, where it had been saved,
    #+ and close fd #6 ( 6<&- ) to free it for other processes to use.
    #
    # <&6 6<&-    also works.
    
    echo -n "Enter data  "
    read b1  # Now "read" functions as expected, reading from normal stdin.
    echo "Input read from stdin."
    echo "----------------------"
    echo "b1 = $b1"
    
    echo
    
    exit 0
    
    Similarly, an exec >filename command redirects stdout to a designated file. This sends all command output that would normally go to stdout to that file.
    
    Important	
    
    exec N > filename affects the entire script or current shell. Redirection in the PID of the script or shell from that point on has changed. However . . .
    
    N > filename affects only the newly-forked process, not the entire script or shell.
    
    Thank you, Ahmed Darwish, for pointing this out.
    

    copy | embed

    0 comments - tagged in  posted by rschu68 on Jun 23, 2010 at 9:12 a.m. EDT
  • image link con target _blank
    <? 
    $img_path = "images/arr_leggi_blu.gif"; 
    $link_path = "node/47";
    $theme_name = 'pmsth';
    
    $options = array(
        'attributes' => array(
            'target' => '_blank',
        ),
        'html' => true,
    );
    
    $img = theme('image',  drupal_get_path('theme', $theme_name). "/$img_path"); 
    print l($img, $link_path, $options);
    
    ?>
    

    copy | embed

    0 comments - tagged in  posted by allaterza on Jun 17, 2010 at 11:27 a.m. EDT
  • link con target _blank
    <?
    $anchor = "anchor text";
    $drupal_path = "node/47";
    $options = array(
        'attributes' => array(
            'target' => '_blank',
        )
    );
    print l($anchor, $drupal_path, $options);
    ?>
    

    copy | embed

    0 comments - tagged in  posted by allaterza on Jun 17, 2010 at 9:44 a.m. EDT
  • a
    a
    

    copy | embed

    0 comments - tagged in  posted by oscar on Mar 26, 2010 at 6:01 p.m. EDT
  • a
    a
    

    copy | embed

    0 comments - tagged in  posted by oscar on Mar 26, 2010 at 5:56 p.m. EDT
  • image link
    <? 
    $img_path = "images/arr_leggi_blu.gif"; 
    $link_path = "node/47";
    $theme_name = 'pmsth';
    
    $img = theme('image',  drupal_get_path('theme', $theme_name). "/$img_path"); 
    print l($img, $link_path, array('html' => true));
    
    ?>
    

    copy | embed

    0 comments - tagged in  posted by allaterza on Feb 06, 2010 at 6:24 a.m. EST
  • queue
    #include <iostream>
    #include <queue>
    using namespace std;
    int main()
    {
        queue<int>myqueue;
        queue<int>myqueue2;
        for(int j=1;j<=10;j++)
        {
            myqueue.push(j);
        }
        int i;
        for(i=myqueue.size();i>0;i--)
        {
            cout<<myqueue.front()<<" ";
            myqueue2.push(myqueue.front());
            myqueue.pop();  //removes the top element
        }
        cout<<endl<<endl;
        for(int h=1;h<=3;h++)
        {
            myqueue.push(myqueue2.front());
            myqueue2.pop();
        }
            for(i=myqueue2.size();i>0;i--)
        {
            cout<<myqueue2.front()<<" ";
            //myqueue2.push(myqueue.front());
            myqueue2.pop();  //removes the top element
        }
            for(i=myqueue.size();i>0;i--)
        {
            cout<<myqueue.front()<<" ";
            //myqueue2.push(myqueue.front());
            myqueue.pop();  //removes the top element
        }
    }
    

    copy | embed

    0 comments - tagged in  posted by Fatal_eX on Jan 18, 2010 at 8:24 p.m. EST
  • Posting a link
    <a href="http://URL" > the link < /a >
    

    copy | embed

    0 comments - tagged in  posted by saravanansaravanan on Jan 17, 2010 at 6:19 a.m. EST
  • A Recursive Example - Factorial
    #include <iostream>
    
    using namespace std;
    
    
    
    int main()
    {
        int i=10;
        int recur_factorial(int i);
        cout<<recur_factorial( i);
    }
    
    
    int recur_factorial(int i)
    {
    	if ( i == 0)
           return 1;
    	else
      {
          return i * recur_factorial(i - 1);
    	}
    }
    

    copy | embed

    0 comments - tagged in  posted by HD on Nov 22, 2009 at 10:09 p.m. EST
  • s1
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
        string s1;
        s1="Singapore Polytechnic is the oldest polytechnic!";
        cout<<s1<<endl;
        s1.replace(29,6,"coolest");
        cout<<s1;
    
    }
    

    copy | embed

    0 comments - tagged in  posted by Fatal_eX on Nov 09, 2009 at 8:10 p.m. EST
  • template
    #include <iostream >
    
    using namespace std;
    
    double l, h, w, Area, Volume;
    template <typename T>
    int calcArea( T h,T w)
    {
        Area = h*w;
    }
    template <typename N>
    int calcVol(N Area, N l)
    {
        Volume = l*Area;
    }
    
    int main()
    {
        cout<<"Please enter height: ";
        cin>>h;
        cout<<"Please enter width: ";
        cin>>w;
        cout<<"Please enter length: ";
        cin>>l;
        calcArea(h, w);
        calcVol(Area, l);
    
    
        cout<<"\nArea : "<<Area<<endl;
        cout<<"Volume : "<<Volume<<endl<<endl;
        cout<<":)"<<endl;
    
        cin.get();
        cin.get();
        return 0;
    }
    

    copy | embed

    0 comments - tagged in  posted by Fatal_eX on Nov 08, 2009 at 10:19 p.m. EST
Sign up to create your own snipts, or login.