您好,欢迎访问三七文档
#include stdio.h putchar(字符表达式) putchar('A'); putchar('A' + 1); putchar(65); putchar('\101'); putchar('\''); putchar('\015'); putchar('\n'); #include stdio.h !int main() { char c = getchar(); putchar(c); ! return 0; } #include stdio.h !int main() { putchar(getchar()); ! return 0; } •printf(格式控制, 输出列表); •输出列表:需要输出的数据或表达式 •格式控制:双引号括起来的字符串 •普通字符 •格式说明: %d, %f……doxucsfeg#include stdio.h !int main() { int a = 1, b = 2; ! printf(a = %d, b = %d\n, a, b); ! return 0; } %d%mdm%-‐mdm%ld%o, %mo, %-‐mo, %lo%x, %mx, %-‐mx, %lx%u %cputcharputchar%s%ms%-‐ms%.ns%f%mf%.nf%e, %me, %.ne%g%f%e%d%D%%%’\45’•scanf(格式控制, 地址列表); •格式控制:同printf •地址列表:数据变量的地址 •普通字符 •格式说明doxcsfescanf%uunsigned%d%o%x%*scanf%c#include stdio.h #include math.h !int main() { float a, b, c, area, s; ! scanf(%f%f%f, &a, &b, &c); ! s = (a + b + c) / 2; area = sqrt(s * (s -‐ a) * (s -‐ b) * (s -‐ c)); ! printf(a = %7.2f, b = %7.2f, c = %7.2f\n, a, b, c); printf(area = %7.2f\n, area); ! return 0; } #include stdio.h !int main() { char c1, c2; c1 = getchar(); printf(%c,%d\n, c1, c1); c2 = c1 + 32; printf(%c,%d\n, c2, c2); ! return 0; }
本文标题:C语言输入输出语句
链接地址:https://www.777doc.com/doc-7118564 .html