C语言实例代码
单分子水的质量约为3.0×10克。一夸脱水约950克。
#include <stdio.h>
int main(void)
时间:2022-07-04
取一个数字,加1,然后减去原始数字。浮点计算可能会给出另一个答案:
#include <stdio.h>
时间:2022-07-04
#include <stdio.h>
#include <math.h>
#defineMAX_INTEREST6
#defineMAX_PERIOD10
int main()
{
int interest;
时间:2022-07-04
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int p, intCircle = 0, intSquare, intToss = 3000, intRM;
时间:2022-07-04
这里给出了无限级数展开的公式:
sin x = x - x3/3! + x5/5! - x7/7! + ...
这里,x是弧度,它取值范围-1 <= x <= 1。
时间:2022-07-04
这里给出了无限级数展开的公式:
cos x = 1 - x2/2! + x4/4! - x6/6! +...
这里,x是弧度,它取值范围-1 <= x <= 1。
时间:2022-07-04
计算二次方程ax ^ 2 + bx + c = 0的根。
由以下公式给出:
(-b + square_root(b2 - 4ac))/2a和(-b - square_root(b2 - 4ac))/2a
时间:2022-07-04
#include <stdio.h>
int main (void)
{
int i1, i2;
printf ("Enter two numbers: ");
scanf ("%i%i", &i1, &i2);
时间:2022-07-04
#include<stdio.h>
int main (void)
{
float result;
float x = 2.55;
result = 3 * x * x * x + 5 * x * x + 6;
时间:2022-07-04
#include<stdio.h>
int main (void){
float result;
result = (3.31e-8 * 2.01e-7) / (7.16e-6 * 2.01e-8);
时间:2022-07-04
#include<stdio.h>
int main (void)
{
float c;
float f = 127.0;
c = (f - 32) / 1.8;
printf("%f degrees Fahrenheit equals %f Celsius \\n", f, c);
时间:2022-07-04
#include <stdio.h>
int main()
{
int numTest;
float stTest, avg, total = 0.0;
for (numTest = 0; numTest < 25; numTest++)
时间:2022-07-04
#include <stdio.h>
#include <stdlib.h>
int main()
{
float height_in_cm;
char height_in_inches[4];
时间:2022-07-04
#include <stdio.h>
#include <stdlib.h>
int main()
{
char weight[4];
int w;
printf("Enter your weight:");
时间:2022-07-04
#include <stdio.h>
#include <stdlib.h>
int main()
{
int houses, hotels, total;
char temp[4];
printf("Enter the number of houses:");
时间:2022-07-04
#include <stdio.h>
int main(void) {
enum FaceValue { two=2, three, four, five, six, seven,
eight, nine, ten, jack, queen, king, ace};
时间:2022-07-04
可以在不指定标记的情况下创建枚举类型的变量,因此没有枚举类型名称。因为没有类型名称,所以以后在代码中无法定义此类型的其他变量。
时间:2022-07-04
使用枚举,可以定义一个新的整数类型,其中类型的变量具有固定的可能值范围。以下是定义名称为Weekday的枚举类型的语句示例:
时间:2022-07-04
#include <stdio.h>
int main(void)
{
printf("Type int has a size of %zd bytes.\\n", sizeof(int));
时间:2022-07-04
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
printf("int %d\\n", sizeof(int));
时间:2022-07-04
#include <stdio.h>
int main()
{
int intarray[100];
float floatarray[100];
double doublearray[100];
printf("\\n\\nSize of int = %d bytes", sizeof(int));
时间:2022-07-04
要确定静态分配的数组的长度,可以使用sizeof运算符:
#include <stdio.h>
int main(void) {
时间:2022-07-04
sizeof运算符将变量名称或数据类型作为参数,并返回将数据存储在内存中所需的字节数。
时间:2022-07-04
以下代码通过将数组大小除以数组数据类型的大小来计算数组中包含的元素数。
时间:2022-07-04
可以使用sizeof运算符计算出给定类型占用的字节数。以下是如何存储应用sizeof运算符产生的值:
时间:2022-07-04
#include <stdio.h>
#include <stdlib.h>
#define LIM 30
char * s_gets(char * st, int n);
int main(){
时间:2022-07-04
#include <stdio.h>
int main()
{
float lightyear=5.878E12;
float jupiter=483400000;
float distance;
distance=jupiter/lightyear;
时间:2022-07-04
#include <stdio.h>
double cubed(double n); // prototype declaration for cubed
int main(void){
double input;
时间:2022-07-04
#include <stdio.h>
#define ADJUST 7.31// one kind of symbolic constant
int main(void){
const double SCALE = 0.333;// another kind of symbolic constant
时间:2022-07-04
#include <stdio.h>
#define ADJUST 7.31// one kind of symbolic constant
int main(void){
const double SCALE = 0.333;// another kind of symbolic constant
时间:2022-07-04