1. There is a four-bit positive integer that makes up the four digits of this four-digit number, and if they are swapped first and last, the second is swapped with the third, forming a new four-digit number. The original four-digit number is 4 times times the new four-digit number, please find a such four-digit number.
#include <stdio.h>intMain () {intA,c; for(a= +; a<=9999; a++) {C=a%Ten* ++ (A/Ten)%Ten* -+ (a% +)/ -*Ten+a/ +; if(a==4*c) {printf ("%d\n", a); } } return 0;}
2. Enter any number of digits to sum the numbers. If within "1,12", output the English name of the month corresponding to the number, otherwise output * * *.
Example: Input 123, output 6 June
Input 12345, Output 15 * * *
#include <stdio.h>intMain () {intsum=0, num; printf ("Enter any number of digits"); scanf ("%d",&num); if(num<Ten) {printf ("Error"); } Else if(num>=Ten) { while(num>0) {sum=sum+num%Ten; Num=num/Ten; } if(sum> A) {printf ("%d ***\n", sum); } Else { Switch(sum) { Case 1:p rintf ("1 January"); Break; Case 2:p rintf ("2 February"); Break; Case 3:p rintf ("3 March"); Break; Case 4:p rintf ("4 April"); Break; Case 5:p rintf ("5 May"); Break; Case 6:p rintf ("6 June"); Break; Case 7:p rintf ("7 July"); Break; Case 8:p rintf ("8 August"); Break; Case 9:p rintf ("9 September"); Break; Case Ten:p rintf ("Ten October"); Break; Case One:p rintf ("November"); Break; Case A:p rintf ("December"); Break; } } } return 0;}
3. Given a positive integer of not more than 6, consider 4 consecutive digits starting from a. Please output all 3 digits of the non-repeating number made up of them.
Input format: The input is given a in a row.
Output format: Outputs a 3-digit number that satisfies the criteria and requires 6 integers per line from small to large. Integers are separated by spaces, but there is no extra space at the end of the line.
#include <stdio.h>intMain () {intA,b,c,d,i=0; printf ("given a positive integer that does not exceed 6"); scanf ("%d",&a); for(b=a;b<a+4; b++) { for(c=a;c<a+4; C + +) { for(d=a;d<a+4;d + +) { if(b!=c&&b!=d&&c!=d) {printf ("%d", b* -+c*Ten+d); I++; if(i%6==0) {printf ("\ n");} }}} } return 0;}
4. Perpetual calendar, see commodity guessing price, automatic quiz, scissors game. (Completion of individual selected topics)
#include <stdio.h>#include<stdlib.h>#include<time.h>intMain () {inti,a,p=0,success=0,fail=0,z=1; CharJ; Do{printf ("* * * * Scissors mini game *****\n"); printf ("round%d showdown \ n", z); printf ("It's your call, please. Select: 1. Stone 2. Scissors 3. Cloth \ n"); scanf ("%d",&a); Srand (Time (NULL)); I=rand ()%3+1; if(a<0|| A>3) {printf ("Error"); } Else if(a==1) {Z++; Switch(i) { Case 1: printf ("You got a rock, a computer, a rock, a draw, come on."); p++; Break; Case 2: printf ("You got a rock, you got a computer scissors, you're lucky, you won."); success++; Break; Case 3: printf ("you're out of the rock, the computer's out of the cloth."); fail++; Break; } } Else if(a==2) {Z++; Switch(i) { Case 2: printf ("You got a rock, a computer, a rock, a draw, come on."); p++; Break; Case 3: printf ("You got a rock, you got a computer scissors, you're lucky, you won."); success++; Break; Case 1: printf ("you're out of the rock, the computer's out of the cloth."); fail++; Break; } } Else if(a==3) {Z++; Switch(i) { Case 3: printf ("You got a rock, a computer, a rock, a draw, come on."); p++; Break; Case 1: printf ("You got a rock, you got a computer scissors, you're lucky, you won."); success++; Break; Case 2: printf ("you're out of the rock, the computer's out of the cloth."); fail++; Break; }} printf ("to continue the next round of games? \ny or n\n"); scanf ("%c",&j); } while(j=='y'|| j=='Y'); printf ("for battle: \ n Combat count:%d\n Computer score:%d\n You score:%d\n Draw number:%d\n\n", z-1,fail,success,p); if(success>fail) {printf ("you won."); } Else if(success<fail) {printf ("you lost."); } Else if(success=fail) {printf ("Draw"); } return 0; }
Sixth time Assignment