#include <stdio.h>
int main()
{
double num = 2.5; //定义浮点型变量num并赋值为2.5
int num1 = (int)num;
printf("num的整数部分是%d\n", num1);
return 0;
}
记得(int)后要跟一个新的变量名称,不能和原变量名称一样
int main()
{
double num = 2.5; //定义浮点型变量num并赋值为2.5
int num1 = (int)num;
printf("num的整数部分是%d\n", num1);
return 0;
}
记得(int)后要跟一个新的变量名称,不能和原变量名称一样
2022-03-30
#include <stdio.h>
int main()
{
int a,b,c,d;
double result;
a = 1;
b = 2;
c = 3;
d = 4;
result = a + b - c * d; //在这里体验哦~
printf("%f\n", result);
return 0;
}
int main()
{
int a,b,c,d;
double result;
a = 1;
b = 2;
c = 3;
d = 4;
result = a + b - c * d; //在这里体验哦~
printf("%f\n", result);
return 0;
}
2022-03-29
#include <stdio.h>
int main(){
int age = 18;
float height = 1.85;
char unit = 'm';
printf("小明今年%d岁\n", age);
printf("小明身高%f%c\n", height, unit);
printf("%s小明现在在慕课网上学习IT技术");
return 0;
}
int main(){
int age = 18;
float height = 1.85;
char unit = 'm';
printf("小明今年%d岁\n", age);
printf("小明身高%f%c\n", height, unit);
printf("%s小明现在在慕课网上学习IT技术");
return 0;
}
2022-03-29
#include<stdio.h>
int main()
{
int i,sum;
for(i=1,sum=0;i<=20;i++)
{
if(i%3==0)
{
continue;
}
sum+=i;
printf("sum=%d\n",sum);
}
return 0;
}
int main()
{
int i,sum;
for(i=1,sum=0;i<=20;i++)
{
if(i%3==0)
{
continue;
}
sum+=i;
printf("sum=%d\n",sum);
}
return 0;
}
2022-03-28
#include <stdio.h>
int main()
{
// 定义相乘数字i,j以及结果result
int i, j, result;
for(i=1;i<=9;i++){
for(j=1;j<=i;j++){
printf(" ");
printf("%d*%d=%d",j,i,result=j*i);
}
printf("\n");
}
return 0;
}
int main()
{
// 定义相乘数字i,j以及结果result
int i, j, result;
for(i=1;i<=9;i++){
for(j=1;j<=i;j++){
printf(" ");
printf("%d*%d=%d",j,i,result=j*i);
}
printf("\n");
}
return 0;
}
2022-03-11
#include <stdio.h>
int main()
{
int x = 0;
printf("x=%d\n",0+x);
printf("x=%d\n",x+2);
return 0;
}
这样对吗
int main()
{
int x = 0;
printf("x=%d\n",0+x);
printf("x=%d\n",x+2);
return 0;
}
这样对吗
2022-03-11
#include <stdio.h>
int main(){
int age = 18;
float height = 1.85;
char unit = 'm';
printf("小明今年%d岁\n", age);
printf("小明身高%f%c\n", height, unit);
printf("小明现在在慕课网上学习IT技术");
return 0;
}
int main(){
int age = 18;
float height = 1.85;
char unit = 'm';
printf("小明今年%d岁\n", age);
printf("小明身高%f%c\n", height, unit);
printf("小明现在在慕课网上学习IT技术");
return 0;
}
2022-03-07
小菜一碟
#include <stdio.h>
#define N 10
void sum(int *);
void high(int *);
void low(int *);
void average(int *);
void sort(int *);
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
sum(score);
high(score);
low(score);
average(score);
sort(score);
return 0;
}
#include <stdio.h>
#define N 10
void sum(int *);
void high(int *);
void low(int *);
void average(int *);
void sort(int *);
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
sum(score);
high(score);
low(score);
average(score);
sort(score);
return 0;
}
#include <stdio.h>
int main()
{
int year = 2014; //今年是2014年
//补全一下代码
if(year%4==0||year%400==0)
{
printf("今年时闰年");
}
else
{
printf("今年是平年");
}
return 0;
}
int main()
{
int year = 2014; //今年是2014年
//补全一下代码
if(year%4==0||year%400==0)
{
printf("今年时闰年");
}
else
{
printf("今年是平年");
}
return 0;
}
2022-02-21