int main()
{
printf("This is a C program.\n");
return 0;
}//zhushi
#include<stdio.h>
int main() {
printf("%d\n", sizeof(char));
printf("%d\n", sizeof(short));
printf("%d\n", sizeof(int));
printf("%d\n", sizeof(long));
printf("%d\n", sizeof(long long));
printf("%d\n", sizeof(float));
printf("%d\n", sizeof(double));
return 0;
}
#include<stdio.h>
int main() {
int a = 123;
int b = 456;
int sum = a + b;
printf(sum);
return 0;
}
char
//字符数据类型short
//短int
//整型long
//长整型long long
//更长的整型float
//单精度浮点数double
//双精度浮点数%d
=整型%f
=float%lf
=double#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
int a = 0;
int b = 0;
int sum = 0;
scanf("%d %d", &a, &b);
sum = a + b;
printf("sum = %d\n",sum);
return 0;
}
printf
=输出函数scanf
=输入函数int main(){
int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
int i = 0;
for (i = 0; i < 10; i++)
{
printf("%d" , arr[i]);
}
return 0;
}
for
循环、arr
内值表示元素个数int main()
{
//数组
int arr[10] = {0} ;
//输入
int i = 0;
for (i = 0; i < 10; i++)
{
scanf ("%d", &arr[i]);
}
//找最大值
int max = arr[0];
//假设数组第一个元素就是最大值
// 那剩下的元素和第一个max比较
// 如果找到比max更大的数,就更新max
for (i = 1; i < 10; i++)
{
if (arr[i] > max)
{
max = arr[i];
}
}
//输出
printf("max = %d", max);
return 0;
}