#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void printCharMan(int line,int col);
void printSpaces(int n);
int main(){
int line,col;
for(line=5,col=5;col<=60;col++){
printCharMan(line,col);
Sleep(50);
system("cls");
}
}
void printSpaces(int n){
int i;
for(i=1;i<=n;i++)
printf(" ");
}
void printCharMan(int line,int col){
int i,j;
for(i=1;i<=line-1;i++)
printf("\n");
printSpaces(col-1);
printf(" o \n");
printSpaces(col-1);
printf("<H>\n");
printSpaces(col-1);
printf("I I\n");
}
#include<stdio.h>
#include<math.h>
int isPrime(int n);
int main(){
int i,s,a=0;
for(i=101;i<=200;i++){
s=isPrime(i);
if(s==i){
printf("%5d",s);
a=a+1;
}
if(s!=0&&a%5==0)
printf("\n");
}
return 0;
}
int isPrime(int n){
int i,m;
m=sqrt(n);
for(i=2;i<=m;i++)
if(n%i==0)break;
if(i>m&&n>1)
return n;
else
return 0;
}
#include <stdio.h>
double fun(int n);
int main(){
int n;
double s;
printf("Enter n(1~10):");
while(scanf("%d",&n)!=EOF){
s=fun(n);
printf("n=%d,s=%f\n\n",n,s);
printf("Enter n(1-10):");
}
return 0;
}
double fun(int n){
double s;
int i,f=1 ,z=1;
for(i=1,s=0;i<=n;)
{
f=f*i;
s=s+z*1/f;
z=-z;
i++;
}
return s;
}
#include<math.h>
#include<stdio.h>
void solve(double a,double b,double c);
int main(){
double a,b,c;
printf("Enter a,b,c:");
while(scanf("%lf%lf%lf",&a,&b,&c)!=EOF){
solve(a,b,c);
printf("Enter a,b,c:");
}
return 0;
}
void solve(double a,double b,double c){
double x1,x2;
double delta,real,imag;
if(a==0)
printf("not quadratic equation.\n");
else{
delta=b*b-4*a*c;
if(delta>=0){
x1=(-b+sqrt(delta))/(2*a);
x2=(-b-sqrt(delta))/(2*a);
printf("x1=%.2f,x2=%.2f\n",x1,x2);
}
else{
real=-b/(2*a);
imag=sqrt(-delta)/(2*a);
printf("x1=%.2f+%.2fi,x2=%.2f-%.2fi\n",real,imag,real,imag);
}
}
}