zoukankan      html  css  js  c++  java
  • 非常规题---交互题

    今天邱神给我们上第一天的课,邱神也是很有意思,特别爱笑!!!巨可爱!!!今天讲了一些杂的知识点,还接触了一个新的题型——交互题。

    什么叫交互题呢?就是一种关于你的程序与电脑代码的交互,比如说你写了一个没有主函数的程序,就是一些实现目标的函数,而spj则给你一段主函数,把两个放在一起,就变成了一个整体函数。

    还有一种就是程序和spj之间有互动,这个用到fflush(stdout);这个函数就可以实现交互了。

    例题:CF679A Bear and Prime 100

    代码:

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    using namespace std;
    int prime[40] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,4,9,25,49};
    char s[20];
    int main()
    {
        int tot = 0;
        int ok = 1;
        for(int i = 0;i <= 18;i++)
        {
            fflush(stdout);
            cout<<prime[i]<<endl;
            scanf("%s",s);
            int l = strlen(s);
    //        for(int i = 0;i < l;i++){
    //            printf("%c",s[i]);
    //        cout<<endl;
            if(s[0] == 'y')
            {
    //            ok = 0;
                tot++;
            }
            if(tot >= 2)
            {
                ok = 0;
                break;
            }
        }
        if(ok == 1)
        printf("prime
    ");
        else
        printf("composite
    ");
        return 0;
    }
  • 相关阅读:
    天气预报APP(2)
    天气预报APP(1)
    android ——网络编程
    android ——Intent
    android ——可折叠式标题栏
    5.1 类,实例,实现,方法
    5.0 面向对象
    python 基础
    模拟实现一个ATM + 购物商城程序
    python 基础
  • 原文地址:https://www.cnblogs.com/DukeLv/p/9398198.html
Copyright © 2011-2022 走看看