求解C程序设计题

来源:百度知道 编辑:UC知道 时间:2024/06/08 09:29:08
1.写出利用函数getche()和putchar()进行字符串的输入/输出,并对字符的个数进行累加并输出结果的程序。
2.编程求解鸡兔同笼问题:已知鸡兔共有头a个,有脚b只,计算鸡兔各是多少只?
3.编程从键盘输入一个三位数,将它们逆序输出。例如输入123,则输出321。

1.#include<stdio.h>
#include<string.h>

int main(){
char c;
int count=0;
for(;(c=getchar())!='\n';){
putchar(c);
count++;
}
printf("\n%d\n",count);
return 0;
}
2.#include <stdio.h>
int main()
{
int j,t,a,b;
printf("Please input a,b:");
scanf("%d,%d",&a,&b);
j=2*a-b/2;
t=b/2-a;
printf("j=%d\nt=%d\n",j,t);
return 0;
}

3.#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
char a[4];
scanf("%s",a);
strrev(a);
printf("%s",a);

return 0;
}

无人知道。。。

1. 稍等。
·····················
2.鸡和兔子问题, <