#include <stdio.h>
int main()
{
float num = 2.5; //定义浮点型变量num1并赋值为2.5
int num1 =(int)num;
printf("num的整数部分是%d\n", num1);
return 0;
}
int main()
{
float num = 2.5; //定义浮点型变量num1并赋值为2.5
int num1 =(int)num;
printf("num的整数部分是%d\n", num1);
return 0;
}
2015-01-15
#include <stdio.h>
int main()
{
int x = 0;
printf("x=%d\n",x++);
printf("x=%d\n",++x);
return 0;
}
我终于搞定了哈哈
int main()
{
int x = 0;
printf("x=%d\n",x++);
printf("x=%d\n",++x);
return 0;
}
我终于搞定了哈哈
2015-01-15
5-6练习题1/1中
C用户定义的函数中如果有return语句,函数可以为void类型
这个选项设定为正确,没明白正确的原因。请教各位。谢谢。
C用户定义的函数中如果有return语句,函数可以为void类型
这个选项设定为正确,没明白正确的原因。请教各位。谢谢。
#include <stdio.h>
#define a 97
int main()
{
char c = 'a';
int n = a; //将c赋值给n
float f = a; //将c赋值给f
double d = a; //将c赋值给d
printf("%d\n",n);
printf("%f\n",f);
printf("%lf\n",d);
return 0;
}
根据上一节课的内容可以这样写
#define a 97
int main()
{
char c = 'a';
int n = a; //将c赋值给n
float f = a; //将c赋值给f
double d = a; //将c赋值给d
printf("%d\n",n);
printf("%f\n",f);
printf("%lf\n",d);
return 0;
}
根据上一节课的内容可以这样写
2015-01-15
#include<stdio.h>
int main(){
int a,b,c,d,e;
a = 5;
b = 9;
c = 18;
d = a + c;
e = d - b;
printf("%d\n%d\n%d\n%d\n",a + d,c - e,b * a,d - a / e);
//仅仅随意写的,不知道为什么double在visula studio 声称有问题
}
int main(){
int a,b,c,d,e;
a = 5;
b = 9;
c = 18;
d = a + c;
e = d - b;
printf("%d\n%d\n%d\n%d\n",a + d,c - e,b * a,d - a / e);
//仅仅随意写的,不知道为什么double在visula studio 声称有问题
}
2015-01-15
#include<stdio.h>
int main(){
double num = 2.4;
int b = (int) num;
printf("num的整数部分是%d\n",b);
}
就这样
int main(){
double num = 2.4;
int b = (int) num;
printf("num的整数部分是%d\n",b);
}
就这样
2015-01-15
#include<stdio.h>
int main(){
int c = 97;
double z,x;
z = x;
x = c;
printf("%d\n",c);
printf("%f\n",x);
printf("%f\n",z);
}
这样就ok
int main(){
int c = 97;
double z,x;
z = x;
x = c;
printf("%d\n",c);
printf("%f\n",x);
printf("%f\n",z);
}
这样就ok
2015-01-15