简单的C语言实现程序
来源:互联网 发布:绿色版软件下载 编辑:程序博客网 时间:2024/04/20 07:53
1.
#include<stidio.h> /* 预处理命令/文件*/
main() /*主函数*/
{
printf(" hello world"); /*输出语句*/
}
2.
#include<math.h> /*one model commond header*/
#include<stdio.h> /* header */
main()
{
double x,s ; /* double model */
printf("intput number:\n");
scanf("%lf",&x); /*
s=sin(x);
printf("sine of %lf is %lf",x,s);
}
3.
#include<stdio.h>
main()
{
int x,y,z;
int max(int a,int b);
printf("input number: \n");
scanf("%d%d",&x,&y);
z=max(x,y);
printf(" maxmun=%d",&z);
}
int max(int a,int b)
{
if(a>b) return a ; else return b ;
}
4.
#include<stdio.h>
main()
{
int i,t;
i=1;
t=2;
while(i<=5)
{
t=t*i;
i=i+1;
}
printf(" t=%d",t);
}
5.
#include<stdio.h>
main()
{
int sigh=1;
float deno=2.0; sum=2.0,term;
while(sigh<=100)
{
sigh=-sigh;
term=sigh/deno;
sum=sum+term;
deno=deno+1;
}
printf("%f",sum);
}
6.
#define PRICE 30
#include<stdio.h>
main()
{
int num ,total ;
num=10 ;
total=num*PRICE;
printf("total=%d",total);
}
7.
#include<stdio.h>
main()
{
int a,b,c,d;
unsingned u;
a=12; b=-24; u=10;
c=a+u;
d=b+u;
pinrtf("a+u=%d,b+u=%d",c,d);
}
8.
#include<stdio.h>
main()
{
int a,b;
a=32767;
b=a+1;
printf("a=%d,b=%d",a,b);
}
9.
#include<stdio.h>
main()
{
long x,y;
int a,b,c,d;
x=5;
y=6;
a=7;
b=8;
c=x+a;
d=y+b:
printf("c=x+a=%d,d=y+b=%d",c,d);
}
10.
#include<stdio.h>
main()
{
printf("%f\n",356.);
printf("%f\n",356);
printf("%f\n",356f);
}
11.
#include<stdio.h>
main()
{
float a,b;
a=123456.789e5;
b=a+20;
printf("%f\n",a);
printf("%f\n",b);
}
12.
#include<stdio.h>
main()
{
float a;
double b;
a=33333.33333;
b=33333.33333333333333;
printf("%f\n%f\n",a,b);
}
13.
#include<stdio.h>
main()
{
int a,b,c;
a=5; b=6; c=7;
printf(" ab c\tde\rf\n");
printf("hijk\tl\bm\n");
}
14.
#include<stdio.h>
main()
{
int a,b;
a=120 ;
b=121 ;
printf("%c,%c\n",a,b);
printf("%d,%d\n",a,b);
}
15.
#include<stdio.h>
main()
{
char a,b;
a='a';
b='b';
a=a-32;
b=b-32;
printf("%c,%c\n%d,%d\n",a,b,a,b);
}
16.
#include<stdio.h>
main()
{
int a-3,b,c=5;
b=a+c;
printf("a=%d,b=%d,c=%d",a,b,c);
}
17.
#include<stdio.h>
main()
{
float pi=3.14159;
int s,r=5;
s=r*r*pi;
printf(" ouput s=%d",s);
}
18.
#include<stdio.h>
main()
{
float f=5.75;
printf("(int)f=%d,f=%f\n",(int)f,f);
}
19.
#include<stdio.h>
main()
{
printf(" \n\n%d,%d\n",20/7,-20/7);
printf("%f,%f\n,20.0/7,-20/7);
}
20.
#include<stdio.h>
main()
{
printf("%d\n",100%3);
}
21.
#include<stidio.h>
Main()
{
Int i=8;
Printf(“%d\n”,++i);
Printf(“%d\n”,--i);
Printf(“%d\n”,i++);
Printf(“%d\n”,i--);
Printf(“%d\n”,-i++);
Printf(“%d\n”,-i--);
Printf(“%d\n”,i);
}
22.
#include<stidio.h>
Main()
{
Int i=5,j=5,p,q;
P=(i++)+(i++)+(i++);
Q=(++j)+(++j)+(++j);
Printf(“%d\n,%d\n,%d\n,%d\n”,p,q,i,j);
}
23.
#include<stdio.h>
Main()
{
Int a,b,c,max,min;
Printf(“Please input number: \n” ) ;
Scanf(“%d%d%d”,&a,&b,&c);
If(a>b)
{ max=a; mai=b ;
}
Else
{ max=b; min=a}
If(max<c)
Max=c;
If(min>c)
Min=c;
Printf(“max=%d\n,min=%d”,max,min) ;
}
24.
#include<stdio.h>
Main()
{
Float a, b ;
Char c ;
Pritnf(“please input expreesion : a+(-,*,/)b\n”);
Scanf(“%f%c%f”,&a,&c,&b);
Switch(c)
{
Case‘+’: printf(“%f”,a+b); break;
Case‘-‘: printf(“%f”,a-b); break;
Case‘*’: printf(“%f”,a*b); break;
Case‘/’: pritnf(“ %f”,a/b); break;
Default : printf(“ input error \n”);
}
}
25.
#include<stidio.h>
Main()
{
Int i ;
Pritnf(“ please input char:“) ;
Scanf(“%d”,&i);
Switch(i)
{
Case 1 : printf(“Monday\n”); break;
Case 2 : printf(“Tuesday\n”); break;
Case 3: printf(“Wednesday\n”); break;
Case 4: printf(“Thursday\n”); break;
Case 5: pritnf(“Friday\n”); break;
Case 6: printf(“Saturday\n”); break;
Case 7: printf(“Sunday\n”); break;
Default: printf(“ Error\n”);
}
}
26.
#include<stdio.h>
Main()
{
Int a,b;
Printf(“Please input two number:“) ;
Scanf(“%d%d”,&a,&b);
Pritnf(“max=%d”,a>b?a:b);
}
27:
#include<stdio.h>
Main()
{
Int a,b ;
Printf(“please input two number:“);
Scanf(“%d%d”,&a,&b);
If(a>b)
Printf(“%d”,a);
Else
Printf(“%d”,b);
}
28.
#include<stdio.h>
Main()
{
Int a,b ;
Printf(“ Please input two number: \n”) ;
Scanf(“%d%d”,&a,&b) ;
If(a==b)
Printf(“a=b\n”);
Else
If(a>b)
Printf(“a>b\n”);
Else printf(“ a<b\n”) ;
}
29.
#include<stdio.h>
Main()
{
Int a,b;
Printf(“ Please input two number:“);
Scanf(“ %d%d”,&a,&b) ;
If(a!=b)
If(a>b) printf(“ a>b\n”);
Else printf(“a<b\n”);
Else printf(“a=b\n”);
}
30.
#include<stdio.h>
Main()
{
Char c ;
Pritnf(“input a character: “);
C=getchar();
If(c<32)
Printf(“ This is a control charactor\n” )
Else if (c>=’0’&&c<=’9’)
Printf(“ This is a digit\n”)
Else if( c>=’A’&&c<=’Z’)
Printf(“ This is a capital letter\n”);
Else if (c>=’a’&&c<=’z’)
Printf(“ This is a small letter\n”) ;
Else
Printf(“ This is an other character\n”) ;
}
31.
#include<stdio.h>
Main()
{
Int a,b ;
Printf(“ input two number:“);
Scanf(“ %d%d”,&a,&b) ;
If(a>b)
Printf(“max=%d”,a);
Else
Printf(“max=%d”,b);
}
32.
#include<stdio.h>
Main()
{
Int ,a,b,max;
Printf(“please input two number: “);
Scanf(“%d%d”,&a,&b);
Max=a;
If(max<b)
Max=b ;
Printf(“max=%d”,max);
}
33.
#include<stdio.h>
Main()
{
Int i,sum=0 ;
I=1;
Loop: if(i<=100)
{
Sum=sum+i;
I=++;
Goto loop;
}
Printf(“%d”,sum);
}
34.
#include<stdio.h>
Main()
{
Int i,sum=0;
I=1;
While(i<=100)
{
Sum=sum+i;
I++;
}
Printf(“%d”,sum);
}
35.
#include<stdio.h>
Main()
{
Int n=0;
Printf(“ input a string: \n”);
While(getchar()!=’\n’)
N++;
Printf(“%d”,n);
}
36.
#include<stdio.h>
Main()
{
Int a=0,n;
Printf(“ Please input number: \n”);
Scnaf(“%d”,n);
While(n--)
Printf(“%d”,a++*2);
}
37.
#include<stdio.h>
Main()
{
Int i,sum=0;
I=1;
Do
{
Sum=sum+i;
I++;
}
While(i<=100);
Printf(“%d”,sum);
}
38.
#include<stdio.h>
Main()
{
Int i,sum=0 ;
I=1;
While(i<=10)
{
Sum=sum+i;
i++;
}
Printf(“sum=%d”,sum);
}
39.
#include<stdio.h>
Main()
{
Int i,j,k;
Printf(“ i j k \n”);
For(i=0; i<2;i++)
For(j=0; j<2; j++)
For(k=0;k<2;k++)
Pritnf(“%d %d %d “,i,j ,k);
}
40.
#include<stdio.h>
Main()
{
Int i=0;
Char c;
While(1)
{
C=’\0’;
While(c!=13&&c!=27)
{
C=getch();
Printf(“ %c\n”,c);
}
If(c==27)
Break;
I++;
Printf(“ The No. Is %d”, i);
}
Printf(“ The end”);
}
41.
#include<stdio.h>
Main()
{
Char c ;
While(c!==13)
{
C=getch();
If(c!==0x1B)
Continue;
Printf(“%c\n”,c);
}}
42.
#include<math.h>
#include<stdio.h>
main()
{
int s;
float n,t,pi;
t=1,pi=0; n=1.0; s=1;
while(fabs(t)>le-6)
{
pi=pi+t;
n=n+2;
s=-s;
t=s/n;
}
pi=pi*4;
printf(" pi=%10.6f\n",pi)
}
43.
#include<stdio.h>
#include<math.h>
main()
{
int m,i,k;
scanf("%d",&m);
k=sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0) break;
if(i>=k+1)
printf("%d is a prime number \n",m);
else
printf("%d is not a prime number \n",m);
}
44.
#include<math.h>
#include<stdio.h>
main()
{
int m,i,k,n=0;
for(m=101;m<=200;m=m+20)
{
k=sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0) break;
if(i>=k+1)
{
printf("%d",m);
n=n+1;
}
if(n%n==0) printf("\n");
}
- 简单的C语言实现程序
- C语言实现的一个简单的HTTP程序
- C语言实现的一个简单的HTTP程序
- C语言实现的一个简单的HTTP程序
- C语言实现的一个简单的HTTP程序
- C语言实现的一个简单的HTTP程序
- C语言实现的一个简单的HTTP程序
- C语言实现的一个简单的HTTP程序
- 简单的C语言程序
- 简单的c语言程序
- c 语言实现的简单屏幕烟花程序
- 一个简单c语言windows程序的实现
- C语言实现简单的分级别写日志程序
- C语言简单校园导游程序的设计与实现
- C语言简单程序
- C语言简单程序
- c语言简单程序
- 简单的的SimpleTron(C语言实现,程序内部实现体验)
- 301 - Transportation
- [android学习]给地图添加要素
- 80386常用内部寄存器
- poj 3352 Road Construction
- php学习 第三十一节
- 简单的C语言实现程序
- 利用Toad管理本地数据库
- NSRunLoop概述及原理
- MyEclipse快捷键
- 电子信息工程专业课程分类介绍
- 视频编解码标准详解介绍
- hdu 1133 Buy the Ticket
- Mysql数据库的导入导出
- Google,Facebook,Twitter,Ebay,腾讯,淘宝网站的技术发展历程