今天邱神给我们上第一天的课,邱神也是很有意思,特别爱笑!!!巨可爱!!!今天讲了一些杂的知识点,还接触了一个新的题型——交互题。
什么叫交互题呢?就是一种关于你的程序与电脑代码的交互,比如说你写了一个没有主函数的程序,就是一些实现目标的函数,而spj则给你一段主函数,把两个放在一起,就变成了一个整体函数。
还有一种就是程序和spj之间有互动,这个用到fflush(stdout);这个函数就可以实现交互了。
例题:CF679A Bear and Prime 100
代码:
#include
#include
#include
#include
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< scanf("%s",s); int l = strlen(s); // for(int i = 0;i < l;i++){ // printf("%c",s[i]); // cout< if(s[0] == 'y') { // ok = 0; tot++; } if(tot >= 2) { ok = 0; break; } } if(ok == 1) printf("prime\n"); else printf("composite\n"); return 0; }