100 cases of Classical C language programming: 1-10 Cases

Source: Internet
Author: User

1. There are 1,2、3, 4 digits, how many three digits of different and no repetition numbers can be formed? How much are they? #include<stdio.h>Main () {inti,j,k,n=0; for(i=1;i<5; i++) for(j=1;j<5; j + +) for(k=1;k<5; k++)if(i!=j&&i!=k&&j!=k) {N++;p rintf ("%d%d%d", i,j,k);if(n%6==0) {printf ("\ n");}} printf ("n=%d\n", n);}2. The issue of wage issuance (1, 10w)0.1(10w,20w)0.075(20w,40w)0.05(40w,60w)0.03(60w,100w)0.015(100w,...)0.01#include<stdio.h>Main () {inti;intu=100000;floatC1,C2,C4,C6,C10,C;C1=u*0.1; C2=c1+u*0.075;/*c4=c2+2u*0.05;c6=c4+2u*0.03;c10=c6+4u*0.015;*/printf ("i="); scanf ("%d",&i);if(i<=T) {C=i*0.1;}Else if(i<=2u) {C=c1+ (i-u) *0.075;}Else{C=i*0.03;} printf ("c=%f\n", c);}//run to the false result, if not use U, run rightly. 3. An integer, plus 100 is a complete square number, plus 168 is a complete square number, what is the number? #include<stdio.h>#include<math.h>Main () {inti,x,y; for(i=1;i<100000; i++) {x=SQRT (i+ -); y=SQRT (i+268);if(x*x==i+ -&&y*y==i+268) printf ("%d\n", i);}} //don't know how to ask for it mathematically?4. Enter a certain month of the year, gets the current day of the year? #include<stdio.h>Main () {intd,m,y,sum,leap;printf ("Please input year-month-day\n"); scanf ("%d-%d-%d",&y,&m,&d);Switch(m) { Case 1: sum=0; Break; Case 2: sum= to; Break; Case 3: sum= -; Break; Case 4: sum= -; Break; Case 5: sum= -; Break; Case 6: sum=151; Break; Case 7: sum=181; Break; Case 8: sum=212; Break; Case 9: sum=243; Break; Case Ten: sum=273; Break; Case  One: sum=304; Break; Case  A: sum=334; Break;default:p rintf ("Data Error"); Break;} Sum=sum+D;if(y% -==0|| (y%4==0&&y% -!=0)) Leap=1;ElseLeap=0;if(leap==1&&m>2) Sum++;p rintf ("It is the%dth day.\n", sum);}5. Enter three integers x, y, Z, please put these three numbers from small to large output. #include<stdio.h>Main () {intx,y,z,t;scanf ("%d%d%d",&x,&y,&z);if(x>y) {T=x;x=y;y=t;}if(x>8) {T=x;x=z;z=t;}if(y>z) {T=y;y=z;z=T;} printf ("Small to big:%d%d%d\n", x, Y, z);}6. Withoutput the letter C pattern. #include<stdio.h>Main () {printf ("Hello c-world!\n");p rintf ("****\n");p rintf ("*\n");p rintf ("*\n");p rintf ("****\n");}7. Title: Output Special pattern, please run in C environment, take a look, Very beautiful!#include<stdio.h>Main () {CharA=176;p rintf ("%c\n", a);} //character problems don't understand8.9*9 multiplication table # include<stdio.h>Main () {inti,j,result;printf ("\ n"); for(i=1;i<Ten; i++){ for(j=1;j<Ten; j + +) {result=i*j;printf ("%d*%d=%-3d", I,j,result);/*-3d = left-aligned, 3-bit*/}printf ("\ n");}} //There are many variants of the multiplication table .9. Requires the output of a chess board. #include<stdio.h>Main () {inti,j; for(i=0;i<8; i++){ for(j=0;j<8; j + +){if((i+j)%2==0) printf ("%d%d",2,2);//The answer is:%c%c, 219,219 don't understandElseprintf (" "); }printf ("\ n");}} Ten. Print Stairs # include<stdio.h>Main () {inti,j;printf ("\1\1\n");/*output of two smiley faces*/ for(i=1;i<5; i++){ for(j=1; j<=i;j++) printf ("*");p rintf ("\ n");}} //There are many variants . 

100 cases of Classical C language programming: 1-10 Cases

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.