# 第三节课

## 复习

``````#include <stdio.h>
int main()
{
a = 13;
printf("%d",a)
}
``````

• 定义变量
• 变量的运算
• 输出语句
• C语言的大体框架

## 读取输入

`scanf` 函数的格式和 `printf` 类似。

``````scanf("%d",&a);
``````

``````scanf("%d",&a); //变量名前需要 &
printf("%d",a); //直接填写变量名
``````

``````#include <stdio.h>
int main()
{
int a;                      //使用变量前，先定义
scanf("%d",&a);              //注意 & 取地址符
printf("您输入的数字是 %d",a);
return 0;
}
``````

``````scanf("%d %d",&a,&b);   //使用空格隔开的读取方法，在输入的时候数据得以空格隔开
scanf("%d,%d",&a,&b);   //同上，输入时，数据须以逗号(,)隔开
``````

## 加法计算器

``````int a, b, c;
``````

``````int a, b, c;
scanf("%d %d",&a,&b);            //读取键盘输入，读取格式是以空格隔开
``````

``````int a, b, c;
scanf("%d %d",&a,&b);            //读取键盘输入，读取格式是以空格隔开

c = a+b;                        //运算：把 a+b 的结果，放在“小盒子” c 里面

printf("%d + %d = %d \n",a,b,c);  //输出整条算式和结果
``````

``````#include <stdio.h>
int main()
{
int a, b, c;

printf("请输入您想要进行加法计算的两个数字，并以空格隔开：")；//可适当加一些文字进行修饰
scanf("%d %d",&a,&b);

c = a+b;

printf("您输入的数据计算结果如下：\n");                   //可适当加一些文字进行修饰
printf("%d + %d = %d \n",a,b,c);
return 0;
}
``````
{"ft_lang_label":"__label__zh","ft_lang_prob":0.930894,"math_prob":0.9964406,"size":1779,"snap":"2023-40-2023-50","text_gpt3_token_len":1349,"char_repetition_ratio":0.13014084,"word_repetition_ratio":0.083333336,"special_character_ratio":0.31646994,"punctuation_ratio":0.18475074,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9863438,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-01T15:25:42Z\",\"WARC-Record-ID\":\"<urn:uuid:5ded150f-5658-4518-b7aa-d55815427d6c>\",\"Content-Length\":\"41368\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:830c7f26-6c6c-449a-8c03-f54aa22b9f8f>\",\"WARC-Concurrent-To\":\"<urn:uuid:186f75f8-6c6c-4461-88f0-b9e0aae91531>\",\"WARC-IP-Address\":\"60.205.214.206\",\"WARC-Target-URI\":\"https://r-bit.doylee.cn/226/\",\"WARC-Payload-Digest\":\"sha1:WWNPV7LIWSRMPCYWRG6IIAQGI4WPBEVK\",\"WARC-Block-Digest\":\"sha1:5SDDTYM7H7ZDPN6FJMBXSXSN6NIR5RRB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100290.24_warc_CC-MAIN-20231201151933-20231201181933-00617.warc.gz\"}"}