猫史档案馆


【Python作品分享】有趣的代码【作品秀】

用户:************查看:3 回复:3 评论:3 创建时间:2020-01-13T14:26:06


【作品展示】

center_image

 

【作品介绍】

无,作者太懒

 

【作品源代码】

//按"1"、"2"控制
#include"stdio.h"
#include"conio.h"
void delay(int x)
{int y
 while(x--)
 for(y=0
     y & lt
     125
     y++)
 {
 }
 }
void pout(int i)
{
    if(i == 1)
    {

        printf("%c", 26)
        delay(1000000)
        printf("\b%c", 0)
    }
    if(i == 2)
    {
        printf("\b%c", 0)

        printf("%c", 27)
        delay(1000000)
        printf("\b%c\b\b", 0)
    }
}
int main()
{
    int a = 1
    while(1)
    {
        if(kbhit())
        {
            a = getch()-48
        }
        pout(a)
    }
    return 0
}
例二:猜一个1~到100的数
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std
int main()
{
    srand(time(0))
    // 生成随机数生成器种子
    int theNumber = rand() % 100+1
    // 1-100的随机数
    int tries = 0, guess
    cout & lt
    & lt
    "\tWecome to Guess My Number\n\n"
    do
    {
        cout & lt
        & lt
        "Enter a guess:"
        cin & gt
        & gt
        guess
        + +tries
        if(guess & gt
           theNumber)
        cout & lt
        & lt
        "Too high!\n\n"
        if(guess & lt
           theNumber)
        cout & lt
        & lt
        "Too low!\n\n"
    }while(guess != theNumber)
    cout & lt
    & lt
    "\nThat's it! You got it in " & lt
    & lt
    tries & lt
    & lt
    " guess!\n"
    return 0
}

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
啦啦啦_啦啦啦_我是编程小渣渣啦啦啦_啦啦啦_我是编程小渣渣

这不是C语言吗

scratch用定义

python用def

c++,c语言用void

 

头文件也无语了

点赞0


评论


开源盛世开源盛世

怎么不加分号

点赞0


评论


QBZ_QBZ_

你不会截图吗

点赞0


评论