typedef unsigned char u8; typedef unsigned int u16; u16 Same_Num(u8 value, u8 num) { u8 i; u16 sum = 0; for(i = 0; i < num; i++) { sum += value * (u16)( pow(10,i)); } return sum; } u16 Same_Num_Sum(u8 value, u8 wei) { u8 n; u16 sum = 0; for(n = 0; n < wei; n++) { sum += Same_Num(value,n+1); } return sum; } int main(void) { u8 a,b; printf ("Please enter some books to sum, for example:\n"); printf("2 + 22 + 222 + 2222 + 22222 (at this time n = 5)\n"); scanf("%d,%d",&a,&b); printf("I want to use %d as the base, and I want to add %d times:",a,b); printf("%d\n", Same_Num_Sum (a, b)); } /*********************end of file***************** **********/ /************************************** ************************************************** *Project Requirements :Classification of a line of character structures *Completion date: 01.13.2018 *Function author: bqgup ********************************* ************************************************** **/ #include<stdio.h>
#include<math.h>
typedef unsigned char u8;
typedef unsigned int u16;
typedef struct
{
char Engliash;
char Null;
char Num;
char Else;
}Add;
Add add = {0,0,0,0};
int main(void)
{
char c;
while((c = getchar()) != '#')
{
if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
typedef unsigned char u8; typedef unsigned int u16; /************************************************************************************ *Function name: Fibonacci sequence number (recursive method) *Completion date: 02.04.2018 *Function author: bqgup **********************************************************************************/ u16 FBNQL(u8 n) { u16 sum; if(n == 1) { sum = 1; } else if(n == 2) { sum = 1; } else if(n > 2) { sum = FBNQL(n - 1) + FBNQL(n - 2); } return sum; } void main(void) { u8 i;//Number of sums u16 a;//Denominator u16 b;//Numerator float sum = 0; for(i = 1; i <= 20; i++) { b = FBNQL(2 + i);//Numerator a = FBNQL(1 + i);//Denominator sum += (float)(b) / (float)(a); } printf("%.2f\n",sum); } /*********************end of file*******************************/ /********************************************************************************************* *Project requirement: Sum the first 20 items of a fractional series *Completion date: 02.04.2018 *Function author: bqgup **************************************************************************************/ #include<stdio.h>
typedef unsigned char u8; typedef unsigned int u16; int main(void) { u8 i = 1; float sum = 100; float high = 100; do { i++; sum = sum / 2; high += (sum * 2); }while(i <= 10); printf("%f\n",sum); printf("%f\n",high); } /*********************end of file***************************/ /********************************************************************************************* *Project requirements: Team A and Team B grouping *Completion date: 02.04.2018 *Function author: bqgup **************************************************************************************/ #include<stdio.h>
typedef unsigned char u8;
typedef unsigned int u16;
int main(void)
{
char i,j;
for(i = 'A'; i <= 'C'; i++)
{
for(j = 'X';j <= 'Z'; j++)
{
if(i == 'A')
{
if(j == 'X')
{
continue;
}
}
if(i == 'C')
{
if(j == 'X' || j == 'Z')
{
continue;
}
}
printf("%c->%c\n",i,j);
}
}
}
/*********************end of file***************************/
typedef unsigned char u8; typedef unsigned int u16; int main(void) { u8 i,j; u8 array[10]; u8 t; printf("Please Input ten numbers:"); for(i = 0; i < 10 ; i++) { scanf("%d",&array); } for(i = 0; i < 9; i++) { for(j = 0; j < 9 - i; j++) { if(array[j + 1 ] < array[j]) { t = array[j + 1]; array[j + 1] = array[j]; array[j] = t; } } } for(i = 0; i < 10; i++ ) { printf("%d ",array); } } /************************end of file****************** ****************/ /******************************************************** ************************************ *Project requirement: Interchange rows and columns of a two-dimensional array *Completion date: 02.05.2018 *Function author:bqgup ********************************************** **********************************************/ #include<stdio.h>
typedef unsigned char u8; typedef unsigned int u16; int main(void) { u8 a[2][3] = {{1,2,3},{4,5,6}}; u8 b[3][2]; u8 i,j; for(i = 0; i < 3; i++) { for(j = 0; j < 2; j++) { b[j] = a[j]; printf("%d ",b[j]); if(j == 1) { putchar('\n'); } } } } /*********************end of file***************************/ /********************************************************************************************* *Project requirement: Find the maximum element in the matrix *Completion date: 02.05.2018 *Function author: bqgup **************************************************************************************/ #include<stdio.h>
typedef unsigned char u8; typedef unsigned int u16; int main(void) { u8 a[][4] = {13,2,3,4,15,6,7,8,9,10,11,5}; u8 i,j,t = 0; u8 q,e; for(i = 0; i < 3; i++) { for(j = 0; j < 4; j++) { printf("%d ",a[j]); if(j == 3) { putchar('\n'); } if(t < a[j]) { t = a[j]; q = i; e = j; } } } printf("The maximum value of the %dth row and %dth column is %d\n",q + 1,e + 1,t); } /*********************end of file***************************/ /************************************************************************************ *Project requirement: string connection *Completion date: 02.05.2018 *Function author: bqgup **************************************************************************************/ #include<stdio.h>
#include <string.h>
typedef unsigned char u8; typedef unsigned int u16; int main(void) { u8 str1[50] = "People's Republic of "; u8 str2[50] = "China"; puts(strcat(str1,str2)); } /*********************end of file*******************************/ /********************************************************************************************* *Project requirement: Find prime numbers* Completion date: 02.06.2018 *Function author: bqgup **************************************************************************************/ /************************************************************************************* Pseudocode analysis: 1. Let the number a be divided by i (the value of i changes from 2 to a - 1) 2. If a can be divided by 2~ (a - 1) If any integer is divisible by a, it means a is definitely not a prime number, and the loop is exited. At this time, i < a **************************************************************************************/ #include<stdio.h>
#include<string.h>
typedef unsigned char u8; typedef unsigned int u16; int main(void) { u8 a; u8 i; printf("Please Input a num:"); scanf("%d",&a); for(i = 2; i <= a - 1; i++) { if(a % i == 0) { break; } } if(i < a) { printf("no prime"); } else { printf("yes prime"); } putchar('\n'); } /*********************end of file***************************/ /********************************************************************************************* *Project requirement: Find prime numbers within 100 using screening method* Completion date: 02.06.2018 *Function author: bqgup **************************************************************************************/ #include<stdio.h>
#include <string.h>
typedef unsigned char u8; typedef unsigned int u16; int main(void) { u8 i,j; for(i = 2; i <= 100; i++) { for(j = 2; j <= i - 1; j++) { if(i % j == 0) { break; } } if(j < i) { printf("%d no prime\n",i); } else { printf("%d yes prime\n",i); } } } /*********************end of file***************************/ /***************************************************************************************** *Project requirement: Sort 10 integers using the selection method *Completion date: 02.06.2018 *Function author: bqgup ******************************************************************************************/ #include<stdio.h>
#include<string.h>
typedef unsigned char u8; typedef unsigned int u16; int main(void) { u8 i,j; u8 a[10]; u8 t; for(i = 0; i < 10; i++) { scanf("%d", &a); } for(i = 0; i < 9; i++) { for(j = 0; j < 9 - i; j++) { if(a[i + 1] < a) { t = a[i + 1]; a[i + 1] = a; a = t; } } } for(i = 0; i < 10; i++) { printf("%d ",a); } } /************************end of file****************** ****************/ /************************************ *************************************************** * *Project requirements: Looking for a 3 X 3 The sum of the diagonal elements of an integer matrix *Completion date: 02.06.2018 *Function author: bqgup **************************** ************************************************** *******/ #include<stdio.h>
#include<string.h>
typedef unsigned char u8;
typedef unsigned int u16;
int main(void)
{
u8 i,j;
u8 a[3][3];
u8 sum = 0;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
scanf("%d",&a[j]);
}
}
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
printf("%d ",a[j]);
if(j == 2)
{
putchar('\n');
}
}
}
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
if(j == i)
{
sum += a[j];
}
}
}
printf("%d\n",sum);
}
/*********************end of file***************************/
The reading experience is very bad. It would be much better to use the method of inserting code blocks#include<stdio.h>#include ......int main(void){}复制代码
Details
Published on 2018-9-8 10:53