转:
#2-1
#include
int main()
{
printf("严嘉禾n");
printf("严n");
printf("嘉禾n");
printf("严嘉禾");
printf("严嘉禾");
getchar();
return 0;
}
#2-2
#include
int main()
{
printf("严嘉禾n");
printf("浙江树人大学致和园");
getchar ();
return 0;
}
int main()
{
int age,day;
age=19;
day=age*days;
printf("你的年龄为%d,天数为%d",age,day);
getchar();
return 0;
}
#include
int jolly();
int deny();
int main()
{
jolly();
jolly();
jolly();
deny();
return 0;
}
int jolly()
{
printf("For he‘s a jolly good fellow!n");
return 0;
}
int deny()
{
printf("Which nobody can deny!n");
return 0;
}
#include
int br();
int ic();
int main()
{
br();
printf(",");
ic();
ic();
br();
return 0;
}
int br()
{
printf("Brazil,Russia");
return 0;
}
int ic()
{
printf("India,Chinan");
return 0;
}
#include
#include
#include
int main()
{
int toes;
toes=10;
printf("toes=%dn",toes);
toes=2*toes;
printf("double toes=%dn",toes);
toes=pow(toes/2,2);
printf("toes square=%dn",toes);
system("pause");
return 0;
}
#include
int s();
int main()
{
s();s();s();
printf("n");
s();s();
printf("n");
s();
getchar();
return 0;
}
int s()
{
printf("Smile!");
return 0;
}
#include
int one_three();
int two();
int main()
{
printf("starting now:n");
one_three();
printf("done!n");
getchar();
return 0;
}
int one_three()
{
printf("onen");
two();
printf("threen");
return 0;
}
int two()
{
printf("twon");
return 0;
}
#include
#include
int main()
{
int x;
printf("输入一个ASCII码:");
scanf("%d",&x);
printf("输出的字符为%cn",x);
system("pause");
return 0;
}
#include
int main()
{
char ch = ‘a‘;
printf("%c",ch);
printf("Starled by the sudden sound,Sally shouted,n");
printf(""By the Great Pumpkin,what was that!"n");
getchar ();
return 0;
}
#include
int main()
{
float input;
printf("Enter a floating-point value:");
scanf("%f",&input);
printf("fixed-point notation:%fn",input);
printf("exponential notation:%en",input);
printf("p notation:%an",input);
return 0;
}
#include
#define S_P_Y 3.156e7
int main()
{
float second,year;
printf("Enter how many year old you are:");
scanf("%f",&year);
second=year*S_P_Y;
printf("You are:%.1f years old.n",year);
printf("And you are %e sconds old,too.n",second);
return 0;
}
#include
#define MOLE 3.0e-23
#define QUART 950
int main()
{
float quart,quantity;
printf("Enter how many quart:");
scanf("%f",&quart);
quantity=quart*QUART/MOLE;
printf("There are %e molecule.n",quantity);
return 0;
}
#include
#define INCH_TO_CM 2.54
int main()
{
float inch,cm;
printf("Enter the inch of your heigh:");
scanf("%f",&inch);
cm=inch*INCH_TO_CM;
printf("Hi,your are %0.2f inch,or %.2f cm heighn",inch,cm);
return 0;
}
#include
#define PINT_CUP 2
#define CUP_OUNCE 8
#define OUNCE_SPOON 2
#define SPOON_TEA 3
int main()
{
float pint,cup,ounce,spoon,tea_spoon;
printf("Enter how many cup:");
scanf("%f",&cup);
pint=cup/PINT_CUP;
ounce=cup*CUP_OUNCE;
spoon=ounce*OUNCE_SPOON;
tea_spoon=spoon*SPOON_TEA;
printf("%.1f cup equals %.1f pint,%.1f ounce,%.1f spoon,%.1f tea_spoon.n",cup,pint,ounce,spoon,tea_spoon);
return 0;
}
#include
int main()
{
char name[40];
char surname[40];
printf("Please input your first name:");
scanf("%s",&name);
printf("Please input your last name:");
scanf("%s",&surname);
printf("Hello,%s,%s.",name,surname);
return 0;
}
#include
int main()
{
char name[40];
int width;
printf("Please input your name:");
scanf("%s",name);
width=printf(""%s"n.",name);
width -=4;
printf(""%20s".n",name);
printf(""%*s".",(width+3),name);
return 0;
}
#include
int main()
{
float input;
printf("Enter a float number:");
scanf("%f",&input);
printf("The input is %.1f or %.1en",input,input);
return 0;
}
#include
int main()
{
float heigh;
char name[40];
printf("Enter your name:");
scanf("%s",name);
printf("Hi %s,how tall you are( inch ):",name);
scanf("%f",&heigh);
printf("%s,you are %.3f feet talln",name,heigh/12.0);
return 0;
}
#include
int main()
{
float speed,size,time;
printf("Pleast input the net speed(megabits per second):");
scanf("%f",&speed);
printf("Pleast input the file size(megabyte):");
scanf("%f",&size);
time = size*8/speed;
printf("At %.2f megabits per second,a file of %.2f megabytes download in %.2f seconds.",speed,size,time);
return 0;
}
#include
int main()
{
char name[40],surname[40];
int wname,wsurname;
printf("Please input your first name:");
scanf("%s",name);
printf("Please input your last name:");
scanf("%s",surname);
wname=printf("%s",name);
printf("");
wsurname=printf("%s",surname);
printf("n%*d %*d",wname,wname,wsurname,wsurname);
return 0;
}
#include
#include
int main()
{
double d_third=1.0/3.0;
float f_third=1.0/3.0;
printf("float of one third(6)=%.6fn",f_third);
printf("float of one third(12)=%.12fn",f_third);
printf("float of one third(16)=%.16fn",f_third);
printf("float of one third(6)=%.6lfn",d_third);
printf("float of one third(12)=%.12lfn",d_third);
printf("float of one third(16)=%.16lfn",d_third);
printf("FLT_DIG in float.h is %dn",FLT_DIG);
printf("DBL_DIG in float.h is %dn",DBL_DIG);
return 0;
}
#include
#define GALLON_TO_LITRE 3.785
#define MILE_TO_KM 1.609
int main()
{
float range,oil;
printf("Pleast input the range you traveled(in mile):");
scanf("%f",&range);
printf("Pleast input the oil you spend(in gallon):");
scanf("%f",&oil);
printf("In UAS,your oil wear is %.1f M/Gn",range/oil);
printf("In Europe,your oil wear is %.1fL/100KM",(oil*GALLON_TO_LITRE)/(range*MILE_TO_KM));
return 0;
}
#include
#define MIN_PER_HOU 60
int main(int argc, char *argv[])
{
int hours, minutes, input;
printf("CONVERT MINUTES TO HOURS!n");
printf("PLEASE INPUT THE NUMBER OF MINUTES( <=0 TO QUIT ):");
scanf("%d",&input);
while(input >0){
hours = input/MIN_PER_HOU;
minutes = input%MIN_PER_HOU;
printf("CONVER TO %d HOUR AND %d MINUTESn",hours,minutes);
printf("PLEASE COMTINUE INPUT THE MUNMBER OF MINUTES( <=0 TO QUIT ):");
scanf("%d",&input);
}
printf("PROGRAM EXIT!n");
}
#include
int main(int argc, char *argv[])
{
int counter, i = 0;
printf("PRINT COUNTINUE 10 NUMBERS!n");
printf("PLEAE IPUT THE START NUMBER :");
scanf("%d",&counter);
while(i++ < 11){
printf(" %d n",counter++);
}
printf("PROGRAM EXIT!n");
return 0;
}
#include
#define WEEK_PER_DAY 7
int main(int argc, char *argv[])
{
int days, weeks, input;
printf("CONVERT DAYS TO WEEKS!n");
printf("PLEASE INPUT THE OF NUMBER OF DAYS( <=0 TO QUIT ):");
scanf("%d",&input);
while(input > 0){
weeks = input/WEEK_PER_DAY;
days = input%WEEK_PER_DAY;
printf("%d days are %d weeks, %d daysn",input,weeks,days);
printf("PLEASE INPUT THE NUMBER OF DAYS( <=0 TO QUIT ):");
scanf("%d,&input");
}
printf("PROGRAM EXIT!n");
return 0;
}
#include
#define FEET_TO_CM 30.48
#define INCH_TO_CM 2.54
int main(int argc,char *argv[])
{
int feet;
float inches, cm;
printf("CONVERT CM TO INCHES!n");
printf("‘Enter the height in centimeters:");
scanf("%f",&cm);
while(cm > 0)
{
feet + cm/FEET_TO_CM;
inches = (cm - feet*FEET_TO_CM)/INCH_TO_CM;
printf("%.1f cm = %d feet , %.1f inchesn",cm,feet,inches);
printf("Enter the height in centimeters( <=0 TO QUIT ):");
scanf("%f",&cm);
}
printf("PROGRAM EXIT!n");
return 0;
}
#include
int main(int argc, char *argv[])
{
int count = 0, sum = 0;
printf("Enter the nember of days you work:");
scanf("%d",&count);
while(count > 0)
{
sum = sum + count--;
}
printf("You earned $ %d total!n",sum);
printf("PROGRAM EXIT!n");
return 0;
}
#include
int main(int argc, char *argv[])
{
int count = 0, sum = 0 ;
printf("Enter the number of days you work:");
scanf("%d",&count);
while(count > 0){
sum = sum + count * count;
count--;
}
printf("You earned $ %d total!n",sum);
printf("PROGRAM EXIT!n");
return 0;
}
#include
double cubic(double n);
int main(int argc, char *argv[])
{
double input;
printf("Enter the double to calc cubic :");
scanf("%1f",&input);
printf("PROGRAM EXIT!n");
return 0;
}
double cubic(double n)
{
double t = n * n * n;
printf("The %lg‘s cubic is %lg !n",n,t);;
return 0;
}
#include
int main(int argc, char *argv[])
{
int first,second;
printf("This program computes moduli.n");
printf("Enter an integer to server as the second operand:");
scanf("%d",&second);
while(first > 0){
printf("%d %% %d is %dn",first,second,(first%second));
printf("Enter next number for first operand( <= 0 to quit):");
scanf("%d",&first);
}
printf("Done!n");
return 0;
}
#include
int Temperatures(double fahrenheit);
int main(int argc,char *argv[])
{
double input;
printf("This program convert fahrenheit to celsius and kelvin.n");
printf("Enter a fahrenheit to start :");
while(scanf("%1f",&input) == 1){
Temperatures(input);
printf("Enter next fahrenheit! ( q to quit): ");
}
printf("Done!n");
return 0;
}
int Temperatures(double fahrenheit)
{
const double F_TO_C = 32.0;
const double C_TO_K = 273.16;
double celsius ,kelvin;
celsius = 5.0/9.0*(fahrenheit - F_TO_C);
kelvin = celsius + C_TO_K;
printf("%.2f. fahrenheit, equal %.2f celsius,and %.sf kelvinn",fahrenheit, celsius,kelvin);
return 0;
}
转:
原文:https://www.cnblogs.com/wangtcc/p/14531570.html