Tcl language Note: Tcl Process Control Exercises

Source: Internet
Author: User

1. Frog Climb Well

 for {Set Day 1;set cur 7} {$cur <77} {incr cur 2 ; incr Day} {}puts $day

2. Add 1 to 100

Proc Getsum {min {max.}} {    0 for     {set I $min} {$i <=$max} {incr i}    {        incr sum $ I    }    return1]

3. Returns the average of any number of integers

proc Getavg {args} {    0    0    foreach n $args {        1        incr sum $n    }      set avg [expr $sum/$i]    " Number of inputs and $sum, average $avg "2 4 6 8 10

4. The format of the required input parameter is Xiao Ming 22 Xiao Li 37 Zhang Hua 54 Lee Mei 8 returns the oldest name

#要求输入的参数的格式为 xiaoming 22 Xiao Li 37 Zhang Hua 54 mei 8 returns the oldest name proc Getmax {args} {    0    ""    foreach {n A} $ args {        if {$a >$i} {            set I $a              set name $n        }    }    return  22 Xiao Li 99 Zhang Hua 54 mei 8]

Tcl language Note: Tcl Process Control Exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.