工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 1039|回复: 2

ZJU-2208不知错哪...请教...谢谢

[复制链接]
发表于 2005-6-22 17:03 | 显示全部楼层 |阅读模式
#include <stdio.h>
#include <string.h>
int main()
{
        int i,j,k,n,len;
        char w[410];
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
        while(1)
        {
                scanf("%d",&n);
                if (n==0) break;
                scanf("%s",w);
                len=strlen(w);
                for (i=0;i<n;i++)
                {
                        j=i+1;
                        while(j<=len)
                        {
                               
                                printf("%c",w[j-1]);
                                j=j+(n+n-i-i-1);
                                if (j>len) break;
                                printf("%c",w[j-1]);
                                j=j+i+i+1;
                        }

                }
                printf("\n");

        }
        return 0;
}
发表于 2005-6-22 17:04 | 显示全部楼层
我贴了代码,你可以这样.你自己随便建立一些测试数据.然后对比两个程序的运行结果.错误的进行跟踪,查找错误的代码
用freopen 函数帮助调试
回复

使用道具 举报

 楼主| 发表于 2005-6-22 17:17 | 显示全部楼层
好办法!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2024-5-29 18:06

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表