C Language Score test, Narcissus number, print star chart

Source: Internet
Author: User

#include <stdio.h>//Input Output header file

#include <string.h>

#include <stdlib.h>

Locally called function 1 score detection

void Test () {

int b;

printf ("Please enter your score \ n");

scanf ("%d", &b);

if (b>=0&&b<=100) {

printf ("Score normal \ n wait for analysis ... \ n ");

if (b<60)

printf ("Idiot, you failed the exam.") \ n ");

else if (b<80)

printf ("Okay, you passed \ n");

Else

printf ("You're good, nice work." \ n ");

}

Else

printf ("Input score error, idiot \ n");

}

Local function 2 Narcissus number

void Test1 () {//single detection

int h,i,j,l;

printf ("Please enter a three-digit number: \ n");

scanf ("%d", &l);

h=l/100;

i=l/10-h*10;

j=l%10;

if (l==i*i*i+j*j*j+h*h*h) {

printf ("%d is the number of daffodils \ n", l);

}

Else

printf ("%d is not narcissus number \ n", l);

}

void Test2 () {//Auto Detect

printf ("Output the number of daffodils from the input number r to 999 \ n");

int o,p,q,r;

scanf ("%d", &r);

while (r<=999)

{

o=r/100;

p=r/10-o*10;

q=r%10;//is assigned to multiple assignments in curly braces and is assigned only once.

if (R==O*O*O+P*P*P+Q*Q*Q)

{

printf ("%d is the number of daffodils \ n", R);

}

r++;

}

}

void Test3 () {//Print star chart

int x, y, Z;

x=5;

y=0;

for (y=0; y<5; y++) {

for (z=1; z<=x+y; z++) {

if (z<x-y) {

printf ("");//Here you can have a variety of second-row keyboard patterns, such as spaces or small bars.

}

Else

printf ("*");

}

printf ("\ n");

}

printf ("fcwm\n");

}

void Test4 () {//Output field Word

int i,j;

for (i=0; i<=4; i++) {

for (j=0; j<=4; J + +) {

if (i%2==0| | j%2==0)

printf ("*");

else printf ("");

}printf ("\ n");

}

printf ("fcwm\n");

}

Main function

int main (int argc, const char * argv[]) {

Insert code here ...

Test ();

Test1 ();//shuixianhua Dange

Test2 ();//shuixianhua Zidong

Test3 ();//dayinxingtu ZD

Test4 ();

/* int a=12;

if (a<12) {

printf ("a<12");

}

else{

printf ("A is not <12\n");

}*/

  /*

Enter multi-person results to view the results;

while (a<100) {//Call while loop

Test ();//jiancechengjidengji

a++;

}

*/

return 0;

}

C Language Score test, Narcissus number, print star chart

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.