搜索
查看: 691|回复: 7
打印 上一主题 下一主题

怎么让计算机从1打印到100再到1? 求编码。

[复制链接]
跳转到指定楼层
楼主
发表于 2014-12-5 19:23:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
5啊哈币

最佳答案

查看完整内容

[mw_shl_code=c,true]#include #include int main() { int a; for(a=1;a=1;--a) printf("%d\n",a); return 0; }[/mw_shl_code]
沙发
发表于 2014-12-5 19:23:54 | 只看该作者
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a;
    for(a=1;a<=100;++a)
        printf("%d\n",a);
    for(a=100;a>=1;--a)
        printf("%d\n",a);
    return 0;
}[/mw_shl_code]
板凳
 楼主| 发表于 2014-12-5 19:31:56 | 只看该作者
例如1 2 3 4 5 ......97 98 99......100...... 99 98 97...... 5 4 3 2 1
地板
 楼主| 发表于 2014-12-5 20:04:39 | 只看该作者
981013 发表于 2014-12-5 19:47
[mw_shl_code=c,true]#include
#include
int main()

system("pause");
这一句你忘加了。

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a;
    for(a=1;a<=100;++a)
        printf("%d\n",a);
    for(a=100;a>=1;--a)
        printf("%d\n",a);
    system("pause");
    return 0;
}
5#
 楼主| 发表于 2014-12-5 20:04:47 | 只看该作者
981013 发表于 2014-12-5 19:47
[mw_shl_code=c,true]#include
#include
int main()

system("pause");
这一句你忘加了。

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a;
    for(a=1;a<=100;++a)
        printf("%d\n",a);
    for(a=100;a>=1;--a)
        printf("%d\n",a);
    system("pause");
    return 0;
}
6#
发表于 2014-12-5 20:16:44 | 只看该作者
Sheldon 发表于 2014-12-5 20:04
system("pause");
这一句你忘加了。

抱歉我在Mac OS X上写的,没必要加这句
7#
发表于 2015-1-1 01:04:17 | 只看该作者
按照学习进度,这个阶段应该是这样写的(WIN 7 64位 啊哈C_v2.0环境下)

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a;
    a=1;
    while(a<100)
    {
    printf("%d\n",a);
     a=a+1;
    }
    while(a>=1)
    {
    printf("%d\n",a);
    a=a-1;
    }   
        system("pause");
        return 0;
}

8#
 楼主| 发表于 2015-2-6 12:21:53 | 只看该作者
"double","%lf","%g"都是什么意思?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表