c 基础代码,C语言的基本编程

1,C语言的基本编程C语言最基本的小程序“Hello World!”#include "stdio.h"main()printf("Hello, world!");getch();return 0;}
2,C语言程序基础printf("area=%f\n"s);s前面少一逗号最后第二行s前要加逗号目前只找到这一个错误华夏联盟(www.hx95.com)为您解答,希望能帮到您倒数第二句输出语句 , 少了中间的逗号!加上就好 。printf("area=%f\n",s);//输出s的值运行截图如下:
3,C语言 基础编程//预处理头文件!#include //main函数 void main() { //声明整型的min,f int min; int f; //输出 printf("Please enter you min Minutes:"); //接受用户赋值 scanf ("%d",&min); //判断 if (min<=2); printf("You fare is 0.2 Yuan. \n"); else//否定上面的判断 {f=(min-3)*0.1+2; printf("you fare is %d. \n"); } return 0; }哇.都是高手这是C#的,呵呵 .long count(int T){if (T <= 3){return 0.2;}else{return (T - 3) * 0.1 + 0.2;}}调用函数即可..#includevoid main() { int min; printf("plese input your min minutes:); scanf("%d"); if(min<=3) printf("Your fare is 0.2 yuan.\n"); else printf("your fare is %d:\n,(min-3)*0.1+0.2"); } 我是改了一下上面的那个兄弟的,有不对之处还请指出,谢谢?。。rintf("\nYour fare is %d.\n",check(min);...更正下 , 落了个)---min));【c 基础代码,C语言的基本编程】
4,求C语言基础代码C菜鸟助手成员tonytvb为你解答(如有疑问请hi我或向我的团队提问):#includeint main()int year,month;scanf("%d %d",&year,&month);if(month>12||monthprintf("year:%d,month:%d\n",year,month);if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)printf("31 days\n");elseif(month==4||month==6||month==9||month==11)printf("30 days\n");elseif((month==2&&year%400==0)||(month==2&&year%4==0&&year%100!=0))printf("29 days\n");else printf("28 days\n");return 0;}#include #include int isLeepYear(int year) return (year%4==0&&year%100!=0||year%400==0);}int getDaysOfMonth(int year,int month) int nDays[13]= if(year12) return 0; nDay=nDays[month]; if(isLeepYear(year)&&month==2) nDay++; return nDay;}int main() int year,month; printf("请输入年份和月份:\n"); scanf("%d %d",&year,&month); printf("%d年%d月有%d天\n",year,month,getDaysOfMonth(year,month)); system("pause"); return 0;}5,C语言基础编程#include#include void main() { float a=3.0,b=4.0,c=5.0,s; s=(a+b+c)*0.5; s=sqrt(s*(s-a)*(s-b)*(s-c)); printf("面积:%f",s); }一楼的不行,二楼的比较好,用二楼的吧!如果你要求边长为3 , 4,5的三角形面积,运行程序后输入3 4 5即可以下为程序源代码,已通过编译调试,可运行:#include "stdio.h"#include "math.h"int main(){double a , b , c; //边长为a,b,cdouble l; //l = ( a + b + c ) / 2double s; //面积printf( "Please input sides of triangle a,b,c: " );scanf( "%lf %lf %lf" , &a , &b , &c );if ( a + b > c && a + c > b && b + c > a ) //判断是否符合构成一个三角形的条件{l = ( a + b + c ) / 2; //求ls = sqrt( l * ( l - a ) * ( l - b ) * ( l - c ) ); //求sprintf( "The area of triangle is: %.3f\n" , s ); //打印s}else{printf( "Invalid sides!\n" ); //输入不合法}return 0;} #include #include main(){ float a,b,c,s,S; a=3; b=4; c=5; s=(1.0/2.0)*(a+b+c); s=(s*(s-a)*(s-b)*(s-c)); S=sqrt(s); printf("%f",S); }#include#include int main() { int a=3,b=4,c=5; float s; s=(a+b+c)*0.5; s=s*(s-a)*(s-b)*(s-c); s=sqrt(s); printf("三角形面积是%f:",s); return 0; }

    推荐阅读