学习小结

来源:互联网 发布:淘宝导航设置颜色代码 编辑:程序博客网 时间:2024/05/20 09:07

1.输出hello world

方法一

#include<stdio.h>

 

Int main()

{

printf“hello world”);

return 0;

}

 

方法二

#include<stdio.h>

 

#include<string.h>

 

Int main()

{

char a[20]

Strcpy(a,”hello world”);

 

Printf(“%s”,a);

 

return 0;

}

 

2.输入年月 输出该年该月多少天

#include<stdio.h>

 

Int main()

{

Int a,m,y;

Scanf(“%d %d”,&y,&m);

Switch(m)

{

Case 1 :

Case 3 :

Case 5:

Case 7:

Case 8:

Case 10:

Case 12:a=31;break;

Case 4 :

Case 6 :

Case 9 :

Case 11 :a=30;break;

}

 

If((((y%4=0)&&(y%100!=0))||(y%400==0))&&(m==2))

{

a=29;

}

Printf(“days=%d”,a);

 

Return 0;

}

 

3.计算器

#include<stdio.h>

Int main()

{

        Int x,y,c,t;

        Printf(“1--2--3--4--\n”);

        Printf(“输入:x 算法 y \n”);

Scanf(“%d %d %d” ,&x,&c,&y);

Switch(c)

{

Case 1 :t=x+y;

Case 2 :t=x-y;

Case 3 :t=x*y;

Case 4 :t=x/y:

Default :printf(“wrong”);

}

Printf(“%d”,t);

 

Return 0;

}

 

 


原创粉丝点击