The C language summary of the freshman semester

Source: Internet
Author: User

Freshman of the last semester to learn some of the C language summary. Very small Pediatrics. I don't know what else to do except arithmetic C. This semester learned some C + + knowledge to add, copied over:

#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <process.h>
#include <time.h>
using namespace Std;
void Main ()
{
void Math ();
void Max ();
void Me ();
void Tuxing ();
void Panduan ();
void time ();
int input;
A:system ("CLS");
printf ("Input 1 uses mathematical function/n");
printf ("Enter 2 uses maximum function/n");
printf ("Enter 3 to display a graph of figures/n");
printf ("Input 4 use judgment function/n");
printf ("Input 0 about author/n");
cout<< "Enter 8 show current Time" <<endl;
cout<< "Enter 9 exit this program" <<endl;
scanf ("%d", &input);
if (input==1) math ();
if (input==2) max ();
if (input==3) tuxing ();
if (input==4) Panduan ();
if (input==0) Me ();
if (input==9) exit (1);
if (input==8) time ();
Goto A;
Getch ();
}


void Math ()
{
float X,y,jia,jian,cheng,chu;
cout<< "Enter two digits" <<endl;
cin>>x>>y;
Jia=x+y;
cout<<x<< "+" <<y<< "=" <<jia<<endl;
Jian=x-y;
cout<<x<< "-" <<y<< "=" <<jian<<endl;
Cheng=x*y;
cout<<x<< "*" <<y<< "=" <<cheng<<endl;
chu=x/y;
cout<<x<< "/" <<y<< "=" <<chu<<endl;

Getch ();
}


void Max ()
{
int z,x,y;
printf ("Enter two digits (hint: with space interval)/n");
scanf ("%d" "%d", &x,&y);
if (x>y)
Z=x;
Else
Z=y;
cout<<x<< "and" <<y<< "the biggest is" <<z<<endl;
Getch ();
}

void Tuxing ()
{void Tuxing_chengfabiao ();
void Tuxing_yanghuisanjiao ();
int input;
printf ("Input 1 shows 99 multiplication table/n");
printf ("Input 2 shows Yang Hui's triangle/n");
scanf ("%d", &input);
if (input==1) Tuxing_chengfabiao ();
if (input==2) Tuxing_yanghuisanjiao ();
}


void Tuxing_chengfabiao ()
{int a,b,s;
for (a=1;a<=9;a++)
{for (b=1;b<=a;b++)
{s=a*b;
printf ("%2d*%2d=%2d", a,b,s);
if (b/a==1)
printf ("n");
}

}
Getch ();
}


#define N 11
void Tuxing_yanghuisanjiao ()
{
int k,i,j,a[n][n]={0};
A[1][1]=1;
for (i=2;i<n;i++)
{for (j=1;j<=i;j++)
A[I][J]=A[I-1][J-1]+A[I-1][J];
}

for (i=1;i<=10;i++)
{for (k=0;k<=40-2*i;k++)
printf ("");
for (j=1;j<=i;j++)
{printf ("%4d", A[i][j]);
if (j/i==1)
printf ("/n/n");
}
}
Getch ();
}

void Panduan ()
{
void Panduan_runnian ();
void Panduan_sushu ();
int input;
printf ("Input 1 use to Judge Leap year function/n");
printf ("Input 2 uses the judged prime function/n");
scanf ("%d", &input);
if (input==1) Panduan_runnian ();
if (input==2) Panduan_sushu ();
}

void Panduan_runnian ()
{int nian,leap;
printf ("Enter year:");
scanf ("%d", &nian);
if (nian%4==0)
{
if (nian%100==0)
{if (nian%400==0)
Leap=1;
Else
Leap=0;
}
Else
Leap=0;
}
Else
Leap=0;
if (leap==1)
printf ("%d years is a leap year", Nian);
if (leap==0)
printf ("%d years is not a leap year", Nian);
Getch ();
}

void Panduan_sushu ()
{int Ture=0,i,shu,yinshu;
printf ("input number");
scanf ("%d", &shu);
for (i=2;i<shu;i++)
{if (shu%i==0)
ture=1;
}
if (ture==1)
cout<<shu<< "Not Prime" <<endl;
cout<<shu<< "The factor is:";
for (i=2;i<shu;i++)
{
if (shu%i==0)
{
yinshu=shu/i;
cout<<yinshu<< "";
}
}
if (ture==0)
printf ("%d is Prime", Shu);
Getch ();
}


void Me ()
{printf ("Name: Sail/n");
cout<< "School: 09 class Software outsourcing class of Qufu Normal University" <<endl;
printf ("e-mail:zf3368485@163.com"); 
Getch ();
}
void Time ()
{
#include <time.h>  
time_t   cur_time;  
Time ( &cur_time);  
char   *timestr=ctime (&cur_time);  
  cout< <timestr<<endl;
Getch ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.