vc++6.0中怎么使用布尔型
/*Program3_7Confusedrecruitionpolicy*/#include<stdio.h>/*#include<stdbool.h>*/intmain...
/*Program 3_7 Confused recruition policy*/
#include <stdio.h>
/*#include <stdbool.h>*/
int main(void)
{
int age=0; /*Age of the applicant*/
int college=0; /*Code for college attended*/
int subject=0; /*Code for subject studied*/
bool interview=false; /*True for accept,false for reject*/
/*Get data on the applicant*/
printf("\nWhat college?1 for Harvard,2 for Yale,3 for other:");
scanf("%d",&college);
printf("\nWhat subject?1 for chemistry,2 for economies,3 for other:");
scanf("%d",&subject);
printf("\nHow old is the applicant?");
scanf("%d",&age);
/*Check out the applicant*/
if((age>25&&subject==1)&&(college==3||college==1))
interview=true;
if(college==2&&subject==1)
interview=true;
if(college==1&&subject==2&&(age<28))
interview=true;
if(college==2&&(subject==2||subject==3)&&age>25)
interview=true;
/*Output decision for interview*/
if(interview)
printf("\n\nGive 'en an interview.");
else
printf("\n\nReject 'em.");
return 0;
}
开始说找不到头文件stdbool.h,我注释掉了以后,错误是bool,false,true都没定义
自己找了个下面的stdbool.h,
/*
stdbool.h
-- Boolean type and values
(substitute for missing C99 standard header)
public-domain implementation from [EMAIL PROTECTED]
implements subclause 7.16 of ISO/IEC 9899:1999 (E)
*/
#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
/* program is allowed to contain its own definitions, so ... */
#undef bool
#undef true
#undef false
#if __STDC_VERSION__ < 199901
typedef int _Bool
#endif
#define bool _Bool
#define true 1
#define false 0
#endif /* !defined(__bool_true_false_are_defined) */
错误是
error C2054: expected '(' to follow '_Bool'
error C2085: 'main' : not in formal parameter list
error C2143: syntax error : missing ';' before '{'
敲代码的时候确实变蓝色了,就是通不过编译,难道是vc的问题?
加上using namespace std;也有错误 展开
#include <stdio.h>
/*#include <stdbool.h>*/
int main(void)
{
int age=0; /*Age of the applicant*/
int college=0; /*Code for college attended*/
int subject=0; /*Code for subject studied*/
bool interview=false; /*True for accept,false for reject*/
/*Get data on the applicant*/
printf("\nWhat college?1 for Harvard,2 for Yale,3 for other:");
scanf("%d",&college);
printf("\nWhat subject?1 for chemistry,2 for economies,3 for other:");
scanf("%d",&subject);
printf("\nHow old is the applicant?");
scanf("%d",&age);
/*Check out the applicant*/
if((age>25&&subject==1)&&(college==3||college==1))
interview=true;
if(college==2&&subject==1)
interview=true;
if(college==1&&subject==2&&(age<28))
interview=true;
if(college==2&&(subject==2||subject==3)&&age>25)
interview=true;
/*Output decision for interview*/
if(interview)
printf("\n\nGive 'en an interview.");
else
printf("\n\nReject 'em.");
return 0;
}
开始说找不到头文件stdbool.h,我注释掉了以后,错误是bool,false,true都没定义
自己找了个下面的stdbool.h,
/*
stdbool.h
-- Boolean type and values
(substitute for missing C99 standard header)
public-domain implementation from [EMAIL PROTECTED]
implements subclause 7.16 of ISO/IEC 9899:1999 (E)
*/
#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
/* program is allowed to contain its own definitions, so ... */
#undef bool
#undef true
#undef false
#if __STDC_VERSION__ < 199901
typedef int _Bool
#endif
#define bool _Bool
#define true 1
#define false 0
#endif /* !defined(__bool_true_false_are_defined) */
错误是
error C2054: expected '(' to follow '_Bool'
error C2085: 'main' : not in formal parameter list
error C2143: syntax error : missing ';' before '{'
敲代码的时候确实变蓝色了,就是通不过编译,难道是vc的问题?
加上using namespace std;也有错误 展开
3个回答
Sievers分析仪
2024-10-13 广告
2024-10-13 广告
是的。传统上,对于符合要求的内毒素检测,最终用户必须从标准内毒素库存瓶中构建至少一式两份三点标准曲线;必须有重复的阴性控制;每个样品和PPC必须一式两份。有了Sievers Eclipse内毒素检测仪,这些步骤可以通过使用预嵌入的内毒素标准...
点击进入详情页
本回答由Sievers分析仪提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询