2.1
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int x = 0, y = 0;
puts("请输入两个整数:");
printf("整数x:");scanf("%d", &x);
printf("整数y:");scanf("%d", &y);
printf("x的值是y的%d%%", (x*100)/y);
return 0;
}
2.2
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int a = 0,b = 0;
puts("请输入两个整数:");
printf("整数a:"); scanf("%d", &a);
printf("整数b:"); scanf("%d", &b);
printf("它们的和是%d,积是%d", a + b, a * b);
return 0;
}
2.3
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
double a = 0;
printf("请输入一个实数:"); scanf("%lf", &a);
printf("你输入的是:%f", a);
return 0;
}