当前位置: 首页 > news >正文

成都建筑网站建设最近一周的新闻

成都建筑网站建设,最近一周的新闻,问卷星网站开发市场调查问卷,建站开发工具目前正在操练TCL,做了两个练习。题目与源码如下:1)写一个过程mysort,有两个参数,input是字符串,type是逆序方式(分为bylist方式和bystring方式,默认bylist方式)。 …
目前正在操练TCL,做了两个练习。题目与源码如下:

    1)写一个过程mysort,有两个参数,input是字符串,type是逆序方式(分为bylist方式和bystring方式,默认bylist方式)。
        
函数原型:proc mysort {input {type bylist}} 
        
例如:
        mysort "hello" bystring 返回的结果是 olleh
        mysort "a b c d" bylist 返回的结果是 d c b a
        mysort "a b c d" 返回的结果是 d c b a
        mysort "abcd" *** 返回的结果是 "type不匹配!请指定bylist或bystring方式"
       
         

#过程mysort,input是字符串,type是逆序方式
proc mysort {input {type bylist}} {
    
set sl [string length $input]
    
set rs ""
    
if {[string compare $type "bystring"]==0 && $sl > 0} {
        
while {$sl>0} {  
        
set temp [string index $input [expr $sl-1]]
        append rs $temp
        incr sl 
-1
        }
        puts $rs
     } 
elseif {[string compare $type "bylist"]==0 && $sl > 0} {
            
set i [expr [llength $input] -1
            
while { $i>=0} { 
            lappend rs [lindex $input $i] 
            incr i 
-1 
        }
        puts $rs
     } 
else {
         puts 
"type不匹配!请指定bylist或bystring方式"
     }
}

2)写一个文件处理函数,将in.txt里的内容读出来,并按照如下形式组合,然后讲组合内容存到out.txt中。
注:
1)     in.txt --> out.txt  的过程中,true转为1,false转为0
2)     每行固定都有9个参数
3)     每行的参数都依次转为单列
4)     函数原型 convert {sourcefile targetfile}
        例如: convert "c:/in.txt" "c:/out.txt"
5)     通过tclsh来调用(用source命令)

in.txt文件形式:

=======================
1 0 1 1 1 23 43 89 99
true false false true true 1 2 3 4
0 0 0 0 1 100 299 300 18
false 0 1 true 1 10 20 10 11
=======================

out.txt文件形式:
=======================
1
0
1
1
1
23
43
89
99
1
0
0
1
1
1
2
3
4
0
0
0
0
1
100
299
300
18
0
0
1
1
1
10
20
10
11
=======================

puts "Please input sourcefile name: "
set sourcefile [gets stdin]
puts 
"Please input targetfile name: "
set targetfile [gets stdin]

proc convert {sourcefile targetfile} {
    #
set sourcefile "c:/in.txt"
    #
set targetfile "c:/out.txt"
    
set line ""                 ;#建立临时list变量
    
set sf [open $sourcefile r] ;#打开源文件
    
set tf [open $targetfile w] ;#打开目标文件
    
    
while {![eof $sf]} { 
        gets $sf line
        
set i [expr [llength $line] -9]
        
while { $i<9} {
            
set b [lindex $line $i]              
            
if {[string compare $b "true"]==0} {  ;#进行true,false替换
                
set b 1
            } 
elseif {[string compare $b "false"]==0} {
                
set b 0
            } 
            puts $tf $b
            incr i
        }
        puts $line
    }
    close $sf                   ;#关闭源文件
    close $tf                   ;#关闭目标文件
}

convert $sourcefile $targetfile

转载于:https://www.cnblogs.com/leowang/archive/2008/01/20/1046306.html

http://www.lbrq.cn/news/2711323.html

相关文章:

  • 网站免费下载软件会员制营销方案
  • 设计网站推荐平面友情链接检查工具
  • 科技网络公司怎么取名字厦门seo排名优化公司
  • 建设教育协会官方网站杭州网站建设技术支持
  • 大连微信网站开发注册网站平台要多少钱
  • 太原网站制作价格百度app下载链接
  • 如何备份网站程序接app推广的单子在哪接
  • 哪些网站可以直接做英文字谜google永久免费的服务器
  • 北京网站优化公司如何名风seo软件
  • 天河网站建设技术百度seo入驻
  • 廊坊手机网站制作郑州seo外包平台
  • 香港建站优化方案做网页设计一个月能挣多少
  • 酒店网站建设的需求分析报告今日热点新闻事件简介
  • 网站seo在线检测网络软文怎么写
  • 深圳宝安医院的网站建设中国万网官网登录
  • wordpress用户注册页面衡阳seo快速排名
  • 英文网站模板做企业网站建设的公司
  • 网站板块的策划方案凡科网站登录入口
  • 前端面试题2022郑州关键词网站优化排名
  • 郑州做网站托管郴州网络推广公司排名
  • wordpress 正版插件sem优化托管公司
  • 做金融网站拘留多久网页设计模板免费网站
  • 哈尔滨网站建设企业怎么让百度收录网址
  • vps如何做网站设计网站模板
  • 石家庄网站制作公司宁波seo推荐推广平台
  • 网站被复制seo优化seo外包
  • 做网站是否过时了怎么让网站被百度收录
  • 成都定制企业网站制作宁波网络推广
  • 佛山网站seo哪家好优化网站排名工具
  • 网站如何获取用户信任seo推广哪家好
  • dkms安装nvidia驱动和多内核支持
  • OpenCV ------图像基础处理(一)
  • 使用EvalScope对GPT-OSS-20B进行推理性能压测实战
  • OpenCV阈值处理详解
  • 2025 电赛 C 题完整通关攻略:从单目标定到 2 cm 测距精度的全流程实战
  • windows git安装步骤