题目1
简答题
#include <stdio.h>
int main()
{
float a=10.6;
float b=13.10;
float c=-3.42;
printf("%d\n",(int)a);
printf("%d\n",(int)b);
printf("%d\n",(int)c);
printf("%d\n",(int)(a+b));
printf("%f\n",(int)a+b+c);
printf("%f\n",(int)(a+b)+c);
printf("%d\n",(int)(a+b+c));
return 0;
}
编程题6
#include <stdio.h>
int main()
{
float a,t;
scanf("%f %f",&a,&t);
printf("%f",0.5*a*t*t);
return 0;
}
编程题7
#include <stdio.h>
int main()
{
float L,dT,dL;
scanf("%f %f",&L,&dT);
dL = L*dT*12*10e-6;
printf("%f",dL);
return 0;
}
编程题8
#include <stdio.h>
int main()
{
float k,d,W;
scanf("%f %f",&k,&d);
W= 0.5*k*d;
printf("%f",W);
return 0;
}
题目2
4
#include <stdio.h>
int main()
{
float x1,y1,x2,y2,x0,y0;
scanf("%f %f %f %f",&x1,&y1,&x2,&y2);
x0=(x1+x2)/2;
y0=(y1+y2)/2;
printf("两点的中点是(%.0f %.0f)",x0,y0);
return 0;
}
5
#include <stdio.h>
#include <math.h>
int main()
{
int a;
scanf("%d",&a);
printf("%f",sqrt(sqrt(a)));
return 0;
}
6
#include <stdio.h>
#include <math.h>
int main()
{
float A,X,R,N;
printf("Enter the amount of the intial despote:");
scanf("%f %f %f",&X,&N,&R);
A = X*pow(1.0 + R/100,N);
printf("%f",A);
return 0;
}
7
#include <stdio.h>
int main()
{
float value,number,discount;
scanf("%f %f %f",&value,&number,&discount);
float all_value,after_value,shui_e,kuan_e;
all_value = value * number;
after_value = all_value*(1-discount);
shui_e = all_value * 0.06;
kuan_e = all_value + shui_e;
printf("%.0f %.0f %.0f %.0f",all_value,after_value,shui_e,kuan_e);
return 0;
}
8
#include <stdio.h>
#include <math.h>
int main()
{
float x,y;
scanf("%f %f",&x,&y);
printf("%.f",sqrt(x*x+y*y));
return 0;
}
9
#include <stdio.h>
#include <math.h>
#define g 9.81
int main()
{
double height,speed;
int i=0;
scanf("%lf",&height);
for(i=0;i<3;i++){
speed=sqrt(2*g*height);
printf("%lf %lf\n",speed,2.0/3*height);
height *= 2.0/3;
}
return 0;
}
题目3
2
#include <stdio.h>
int main()
{
double item,price;
int date1,date2,date3;
printf("Enter item number:");
scanf("%lf",&item);
printf("Enter unit price:");
scanf("%lf",&price);
printf("Enter purchase date(mm/dd/yy):");
scanf("%d/%d/%d",&date1,&date2,&date3);
printf("Item\t\tUnit\t\tPurchase\t\t\n");
printf("\t\tPrice\t\tDate\t\t\n");
printf("%.0lf\t\t$ %.2lf\t%d/%d/%d\t\t",item,price,date1,date2,date3);
return 0;
}
3
#include <stdio.h>
int main()
{
int num1,num2,num3,num4,num5;
printf("Enter ISBN:");
scanf("%d-%d-%d-%d-%d",&num1,&num2,&num3,&num4,&num5);
printf("GSI perfix:%d\n",num1);
printf("Group identifier:%d\n",num2);
printf("Publisher code:%d\n",num3);
printf("Item number:%d\n",num4);
printf("check digit:%d\n",num5);
return 0;
}
5
#include <stdio.h>
int main()
{
int a[4][4];
int i,j,n;
for(i=0;i<4;i++){
for(j=0;j<4;j++){
scanf("%d",&n);
a[i][j]=n;
}
}
printf("Row sums: ");
for(i=0;i<4;i++){
int sum=0;
for(j=0;j<4;j++){
sum+=a[i][j];
}
printf("%d ",sum);
}
printf("\nColumn sums: ");
for(j=0;j<4;j++){
int sum=0;
for(i=0;i<4;i++){
sum+=a[i][j];
}
printf("%d ",sum);
}
printf("\nDiagonal sums: ");
int sum1=0,sum2=0;
for(i=0;i<4;i++){
sum1 +=a[i][i];
sum2 +=a[i][3-i];
}
printf("%d %d",sum1,sum2);
return 0;
}
/* Adds two fractions*/
#include <stdio.h>
int main()
{
int num1,denom1,num2,denom2,result_num,result_denom;
printf("Enter fraction:");
scanf("%d/%d+%d/%d",&num1,&denom1,&num2,&denom2);
result_num = num1 * denom2+ num2 * denom1;
result_denom=denom1 * denom2;
printf("The sum is %d/%d\n",result_num, result_denom);
return 0;
}
题目4
#include <stdio.h>
int main()
{
int a[3];
for(int i=0 ; i<3 ; i++) scanf("%1d",a+i);
for(int i=0;i<3;i++){
printf("%d ",a[2-i]);
}
return 0;
}
或者采取另一种方式
#include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
int m=n;
printf("%d ",n%10);
n /=10;
printf("%d ",n%10);
printf("%d ",m/100);
return 0;
}