C Language 10 Classic Applet

Source: Internet
Author: User
"Program 1"
Title: There are 1, 2, 3, 4 numbers, can make up how many different and no repetition of the number of three digits? How much are they?
1. Program Analysis: Can be filled in the hundred, 10 digits, digit digits are 1, 2, 3, 4. Make up all the permutations and then go
Out of the arrangement that does not satisfy the condition.
2. Program Source code:

Main () {int i,j,k; printf ("\ n"); for (i=1;i<5;i++)//* The following is a triple loop */for (j=1;j<5;j++) for (k=1;k<5;k++) {     if (i!=k&&i!=j&&j!=k)/* Make sure I, J, K three bits are different */printf ("%d,%d,%d\n", i,j,k); } }

"Program 2"
Title: The bonuses awarded by the Enterprise are based on the profit commission. Profit (I) less than or equal to $100,000, bonus can be raised by 10%; high profit
At $100,000, below $200,000, the portion under $100,000 is 10% commission, higher than $100,000, cocoa
7.5%, 200,000 to 400,000, higher than 200,000 yuan, can be a commission of 5%, 400,000 to 600,000 is higher than
400,000 yuan of the portion, can be 3%, 600,000 to 1 million, higher than 600,000 yuan portion, can be a commission of 1.5%, higher than
1 million yuan, the portion of more than 1 million yuan by 1% Commission, from the keyboard input the month profit I, the total bonus should be issued?
1. Program Analysis: Please use the axis to demarcation, positioning. Note that the bonus definition should be defined as the growth integral type.
2. Program Source code:

Main () {int i,j,k; printf ("\ n"); for (i=1;i<5;i++)//* The following is a triple loop */for (j=1;j<5;j++) for (k=1;k<5;k++) {     if (i!=k&&i!=j&&j!=k)/* Make sure I, J, K three bits are different */printf ("%d,%d,%d\n", i,j,k); } }

"Program 2"
Title: The bonuses awarded by the Enterprise are based on the profit commission. Profit (I) less than or equal to $100,000, bonus can be raised by 10%; high profit
At $100,000, below $200,000, the portion under $100,000 is 10% commission, higher than $100,000, cocoa
7.5%, 200,000 to 400,000, higher than 200,000 yuan, can be a commission of 5%, 400,000 to 600,000 is higher than
400,000 yuan of the portion, can be 3%, 600,000 to 1 million, higher than 600,000 yuan portion, can be a commission of 1.5%, higher than
1 million yuan, the portion of more than 1 million yuan by 1% Commission, from the keyboard input the month profit I, the total bonus should be issued?
1. Program Analysis: Please use the axis to demarcation, positioning. Note that the bonus definition should be defined as the growth integral type.
2. Program Source code:

Main () {long int i; int bonus1,bonus2,bonus4,bonus6,bonus10,bonus; scanf ("%ld", &i); bonus1=100000*0.1;bonus2= bonus1+100000*0.75; bonus4=bonus2+200000*0.5; bonus6=bonus4+200000*0.3;  bonus10=bonus6+400000*0.15;  if (i<=100000) bonus=i*0.1;     else if (i<=200000) bonus=bonus1+ (i-100000) *0.075;        else if (i<=400000) bonus=bonus2+ (i-200000) *0.05;           else if (i<=600000) bonus=bonus4+ (i-400000) *0.03;              else if (i<=1000000) bonus=bonus6+ (i-600000) *0.015; else bonus=bonus10+ (i-1000000) *0.01; printf ("bonus=%d", bonus); }

"Program 3"
Title: An integer, which plus 100 is a complete square number, plus 168 is a complete square number, what is the number?
1. Procedure analysis: In 100,000 to judge, first the number plus 100 after the root, and then the number plus 268 after the root, if the root after
The result satisfies the following conditions, i.e. the result. Please see the specific analysis:
2. Program Source code:

#include "math.h" main () {long int i,x,y,z; for (i=1;i<100000;i++) {x=sqrt (i+100);   /*x is the result of adding 100 after the radical (*/y=sqrt (i+268);   /*y is the result of adding 168 after the radical, */if (x*x==i+100&&y*y==i+268)/* If the square root of a number of squares equals that number, which indicates that this number is the total square number */printf ("\n%ld\n", I); } }

"Program 4"
Title: Enter a certain day of the year, judging the day is the first of the year?
1. Procedure analysis: Take March 5 as an example, should first add up the first two months, and then add 5 days that is the first day of this year, special
Case, Leap year and enter the month greater than 3 o'clock need to consider more than one day.
2. Program Source code:

Main () {int day,month,year,sum,leap; printf ("\nplease input year,month,day\n"); scanf ("%d,%d,%d",&year,& Month,&day);  Switch (month)/* First calculates the total number of days of the month prior to months */{case 1:sum=0;break;  Case 2:sum=31;break;  Case 3:sum=59;break;  Case 4:sum=90;break;  Case 5:sum=120;break;  Case 6:sum=151;break;  Case 7:sum=181;break;  Case 8:sum=212;break;  Case 9:sum=243;break;  Case 10:sum=273;break;  Case 11:sum=304;break;  Case 12:sum=334;break; defaultrintf ("Data Error");  } Sum=sum+day; /* Plus days of the day */if (year%400==0| | (year%4==0&&year%100!=0))  /* judgment is not leap year */leap=1; else leap=0; if (leap==1&&month>2)/* If it is a leap year and the month is greater than 2, the total number of days should be one day */sum++; printf ("It's the%dth day.", sum); }

"Program 5"
Title: Enter three integers x, y, Z, please put these three numbers from small to large output.
1. Procedure analysis: We find a way to put the smallest number on X, first compare x with Y, if x>y the value of x and Y to Exchange,
Then the x and Z are compared, and if X>z then the value of X and Z is exchanged, so that x can be minimized.
2. Program Source code:

Main () {int x,y,z,t; scanf ("%d%d%d", &x,&y,&z), if (x>y)/* Swaps the value of x, Y */if (X>Z)/* Exchange X,z Value */if (Y>Z)/* Value for Z,y */printf ("Small to big:%d%d%d\n", X, Y, z); }

"Program 6"
Title: Use the * number to output the letter C pattern.
1. Program Analysis: You can first use the <|>*<|> number on the paper to write the letter C, and then branch output.
2. Program Source code:

#include "stdio.h" main () {printf ("Hello c-world!\n"), printf ("****\n"), printf ("*\n"); printf ("* \ n"); printf ("****\ n "); }

"Program 7"
Title: Output Special pattern, please run in C environment, take a look, Very beautiful!
1. Program Analysis: A total of 256 characters. Different characters, graphics are not the same.
2. Program Source code:

#include "stdio.h" main () {char a=176,b=219; printf ("%c%c%c%c%c\n", b,a,a,a,b); printf ("%c%c%c%c%c\n", a,b,a,b,a); printf ("%c%c%c%c%c\n", a,a,b,a,a); printf ("%c%c%c%c%c\n", a,b,a,b,a); printf ("%c%c%c%c%c\n", b,a,a,a,b); }

"Program 8"
Title: Output 9*9 formula.
1. Program Analysis: Branch and column considerations, a total of 9 rows 9 columns, I control row, J control column.
2. Program Source code:

#include "stdio.h" main () {int i,j,result;  printf ("\ n");      for (i=1;i<10;i++) {for (j=1;j<10;j++) {result=i*j; printf ("%d*%d=%-3d", I,j,result),/*-3d for left-aligned, 3-bit */} printf ("\ n"); */* line break after each line */}}

"Program 9"
Title: Requires the output of chess chessboard.
1. Program Analysis: With I control line, J to control the column, according to the I+j and changes to control the output of black squares, or white squares.
2. Program Source code:

#include "stdio.h" main () {int i,j; for (i=0;i<8;i++) {for (j=0;j<8;j++) if ((i+j)%2==0) printf ("%c%c", 219,    219);    else printf ("");   printf ("\ n"); } }

"Program 10"
Title: Print the stairs while printing two smiley faces on top of the stairs.
1. Program Analysis: With I control line, J to control the column, J according to I change to control the number of output black squares.
2. Program Source code:

#include "stdio.h" main () {int i,j; printf ("\ n");/* Output Two smiley */for (i=1;i<11;i++) {for (j=1;j<=i;j++) printf ("%c%c  ", 219,219);   printf ("\ n"); } }
  • Related Article

    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.