①与C语言一样输出可以用printf(),与Java一样可以用print()println()
#include <stdio.h>
int main() {
int num = 10;
float pi = 3.14159;
char ch = 'A';
char str[] = "Hello, World!";
int* ptr = #
printf("整数:%d\n", num);
printf("浮点数:%f\n", pi);
printf("字符:%c\n", ch);
printf("字符串:%s\n", str);
printf("指针:%p\n", ptr);
printf("十六进制整数:%x\n", num);
return 0;
}
②而scala特有的格式在原来的基础上在括号里面发生了改变——(s"$输出变量名")
print("%d",c)
print(s"$c");
println("%d",c)
println(s"$c")
printf("%d",c)
printf(s"$c")