手抄代码

[TOC] #一

1-1

//c语言的语句以分号结尾。

    main()
    {
        printf("hello, world\n")
    }

//总结这是构成语法规则的一部分,不能少。

1-2

//函数是有某种功能的部件,只能处理它的有限功能。

    main()
    {
        printf("hello, world\y");
        printf("hello, world\7");
        printf("hello, world\?");
    }

//函数声明,定义,使用,需要一致。

1-3

// 对数数进行格式化处理的程序,函数与语法相结合。

    #include <stdio.h>
    main()
    {
        float fahr, celsius;
        int lower, upper, step;
        lower = 0;
        upper = 300;
        step = 20;
        printf("Fahr Celsius\n");
        fahr = lower;
        while(fahr <= upper)
        {
            celsius = (5.0/9.0) * (fahr-32.0);//注意整数相除结果也是整数,3/2==1;2/3 = 0;
            printf("%3.0f   %6.1f\n", fahr, celsius);
            fahr += step;
        }
    }

//while的用法要在块中更新判断的一个值,以便退出,

1-4

//函数功能更改

#include <stdio.h>
main()
{
    float fahr, celsius;
    int lower, upper, step;
    lower = 0;
    upper = 300;
    step = 20;
    printf("%3.0f   %6.1f\n", celsius, fahr);
    while (Celsius <=upper) {
        Fahr = (9.0*Celsius) / 5.0 + 32.0;
        printf("%3.0f %6.1f\n", Celsius, fahr);
        celsius += step;
    }
}

//2xa=b; b/2=a;

转载于:https://my.oschina.net/dengwo/blog/679668

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用Android Studio制作报的步骤: 1.创建一个新的Android Studio项目,选择空活动。 2.在项目中创建一个新的XML布局文件,用于报的设计。可以使用LinearLayout或RelativeLayout等布局。 3.在布局文件中添加所需的组件,例如TextView、ImageView、Button等。可以使用颜色、图片、文本等来装饰报。 4.在MainActivity.java文件中,使用findViewById()方法获取布局文件中的组件,并对其进行操作。例如,可以使用setText()方法设置TextView的文本,使用setImageResource()方法设置ImageView的图片等。 5.在AndroidManifest.xml文件中,添加必要的权限,例如读写外部存储器的权限,以便保存报。 6.运行应用程序,查看报的效果。如果需要,可以进行调整和修改。 下面是一个简单的示例代码,用于在Android Studio中制作报: ```xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 添加背景图片 --> <ImageView android:id="@+id/imageView" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/background" /> <!-- 添加标题 --> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="报" android:textSize="30sp" android:textColor="#FFFFFF" android:layout_marginTop="50dp" android:layout_centerHorizontal="true" /> <!-- 添加内容 --> <TextView android:id="@+id/content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="这是一份报,用于演示Android Studio的制作方法。" android:textSize="20sp" android:textColor="#FFFFFF" android:layout_marginTop="150dp" android:layout_centerHorizontal="true" /> <!-- 添加保存按钮 --> <Button android:id="@+id/saveButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="保存" android:textSize="20sp" android:textColor="#FFFFFF" android:background="@drawable/button_background" android:layout_marginTop="300dp" android:layout_centerHorizontal="true" /> </RelativeLayout> ``` ```java public class MainActivity extends AppCompatActivity { private ImageView imageView; private TextView title; private TextView content; private Button saveButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 获取布局文件中的组件 imageView = findViewById(R.id.imageView); title = findViewById(R.id.title); content = findViewById(R.id.content); saveButton = findViewById(R.id.saveButton); // 设置组件的属性 title.setText("报"); content.setText("这是一份报,用于演示Android Studio的制作方法。"); // 保存报 saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO: 保存报到外部存储器 } }); } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值