入门选手试了一个求平均值的代码,但是不能求出平均值,有没有兄弟帮忙看看
#include <stdio.h>int main()
{
int a,b,ave;
scanf("%d,%d",&a,&b);
ave=(a+b)/2;
printf("The average is %d:\n",ave);
return 0;
}
#include <stdio.h> #pragma GCC diagnostic ignored "-Wpointer-to-int-cast" int main(int argc, char *argv[]) { int a, b, avr; a = (char)("cherry" + 3); b = (char)("梨" + 1); avr = (a + b) >> 1; puts("cherry xiaojieje chao ke ai, duck duck!!"); printf("The average [%d + %d] = %d\n", a, b, avr); return 0; }
[此贴子已经被作者于2021-9-23 21:44编辑过]