Chapter I.
#include <stdio.h>
#include <math.h>
void fun_1 ()//Draw cosine line
{
Double y;
int m, x;
for (y = 1; y >=-1; y-= 0.1)
{
m = ACOs (y) *10;
for (x = 1, x < m, x + +) printf ("");
printf ("*");
for (; × < 62-m; x + +) printf ("");
printf ("*\n");
}
int x_1, y_1;
x_1 = 0;
for (y_1 = 0; y_1 <=; y_1++)
for (x_1=0;x_1<=y_1;x_1++) {
if (x_1==y_1) {
printf ("*\n");
}
else {
printf ("");
}
}
}
void Fun_2 () {
int i, max, Min, sum=0, num[4] = {20,90,85,84};
max = min = num[0];
printf ("max%d\n", Max); printf ("min%d\n", min);
printf ("score:\n");
for (i = 0; i < 4; i++)
printf ("%d\n", Num[i]);
for (i = 0; i < 4; i++)
{
Sum + = Num[i];
if (Max < num[i])
{
max = Num[i];
}
if (min > num[i]) min = num[i];
}
sum = sum-max-min;
printf ("avg%dmin%dmax%d", Sum/2,min,max);
}
void Fun_3 () {
int i;
The value of long j;//n
j = 555555;
for (i = 999; i >; i--)
{
if (j%i = = 0)
{
printf ("factor:%d", I);
Break
}
}
}
void Fun_4 () {
int x, y,last=1;
x = 13;
for (y = x; y > 0; y--)
{
last = last*x%1000;
}
printf ("%d", last);
}
void Fun_5 ()
{
int A, count = 0;
for (a = 5; a <=; a = a + 5)
{
count++;
if (! ( A%)) count++;
}
printf ("%d", count);
}
void Fun_6 ()
{
int A, B, C, count=0;
for (a = 1; a <= 5; a++)
for (b = 1; b <= 5; b++)
for (c = 1; C <= 5 && A! = B; c + +)
if (c! = a&&c! = b) count++;
printf ("%d", count);
}
void Fun_7 ()
{
int n = 13,i,j;
for (i = 0; i < n; i++) {
for (j = 0; J < 12-i; J + +) printf ("");
for (j = 1; J < i + 2; j + +) printf ("%6d", Fun_7_f (i, j));
printf ("\ n");
}
}
int fun_7_f (int x,int y)//fun_7 child function recursively
{
int z;
if (y = = 1 | | y ==x + 1) return 1;
z = (x-1, y-1) + (x-1, y); return z;
}
void Fun_8 ()
{
int data[16];
int i = 0;
int x=98;
printf ("%d\n", X);
for (i = 0;i<8; i++)
{
Data[i] = x% 2;
x = x/2;//printf ("%d\n", X);
printf ("%d\n", Data[i]);
}
for (i = 8; i > 0; i--)
{
if (data[i] = = 1)
for (; I >= 0; i--) printf ("%d", data[i]);
}
}
int main ()
{
Fun_1 ();//Draw cosine line
Fun_2 ();//singer Grand Prix
Fun_3 ();//ask for maximum approximate
Fun_4 ();//The mantissa of the higher order number
Fun_5 ();//class Mantissa 0 numbers
Fun_6 ();//three children five books
Fun_7 ();//Yang Hui triangle
Fun_8 ();//Binary conversion
return 0;
}
C Language 100 Programming examples