数据类型
代码:
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h>int main() { int i = 4; double d = 4.0; char s[] = "HackerRank ";
// Declare second integer, double, and String variables.声明第二个int ,double ,字符数组 int i1; double d1; char s1[200]; // Read and save an integer, double, and String to your variables.读取并保存上面输入的值 scanf("%d",&i1); scanf("%lf",&d1); scanf("%*[\n]%[^\n]",s1); //这里看上一篇预习的解析。 // Print the sum of both integer variables on a new line.打印两个整数的和 printf("%d\n",i+i1);
// Print the sum of the double variables on a new line.打印两个浮点数的和,并控制输出位数 printf("%.1lf\n",d+d1); // Concatenate and print the String variables on a new line.连接两个字符串(考虑拼接函数) printf("%s%s\n",s,s1); // The 's' variable above should be printed first.
return 0;