/***********************第2题***************************************/
#include
#include
int fellTree(int l, int m);
int main(void)
{
int l, m,n;
n=l = m = 0;
printf("请输入道路旁,树的坐标长度:L=");
scanf_s("%d", &l);
printf("请输入修建铁路条数:m=");
scanf_s("%d",&m);
n = fellTree(l, m);
printf("这行树被你伐的只剩下%d棵了!^_^\n",n);
system("pause");
return 0;
}
int fellTree(int l,int m)
{
int i;
int min, max, x, y, tmp;
min = max = x=y=0;
for (i = 0; i
scanf_s("%d", &x);
printf("请输入第%d个点,y坐标:=", i + 1);
scanf_s("%d", &y);
//第一次输入坐标值,比较x,y,如x>y,交换x,y并分别赋给min,max
if (0 == i) {
if (x > y) {
tmp = x;
x = y;
y = tmp;
}
min = x;
max = y;
}
//后续输入的坐标x,y分别与min,max比较,取最大和最小值赋给min,max
else {
if (x < min)
min = x;
else
if (x > max)
max = x;
if (y < min)
min = y;
else
if (y > max)
max = y;
}
}
if (max >= l)
return min;
else
return (l - max) + min;
}
/***********************第3题***************************************/
#include
#include
int main(void)
{
char c;
char buffer[1024];
int i=0;
while ((c = getchar()) != '#') {
if ((c >= 'B'&&c <= 'Z') || (c >= 'b'&&c <= 'z')) {
switch (c)
{
case 'o':
break;
case 'e':
break;
case 'i':
break;
case 'u':
break;
case 'O':
break;
case 'E':
break;
case 'I':
break;
case 'U':
break;
default:
if (c <= 'Z')
c += 32;
else
c -= 32;
buffer[i++] = '.';
buffer[i++] = c;
break;
}
}
else{
printf("%c", '\a');
}
}
buffer[i] = '\0';
printf("%s\n", buffer);
system("pause");
return 0;
}
/***********************第4题***************************************/
#include
#include
int main(void)
{
int m, n, a;
int tmp1, tmp2;
int k;
m = n = a=0;
printf("请输入矩形长:n=");
scanf_s("%d", &n);
printf("请输入矩形宽:m=");
scanf_s("%d", &m);
printf("请输入正方形边长:a=");
scanf_s("%d", &a);
tmp1 = tmp2 = a;
while (tmp1
tmp1 += a;
}
while (tmp2
tmp2+= a;
}
k = tmp1*tmp2 / (a*a);
printf("至少需要%d块正方形\n", k);
system("pause");
return 0;
}