![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
练习
BLANK-BLACK
编程小菜鸟T^T
展开
-
从键盘输入n和a的值,计算a+aa+aaa+...+aa...a(n个a)的值。
4.从键盘输入n和a的值,计算a+aa+aaa+…+aa…a(n个a)的值。逻辑分析:设N=4,a=3;3 x 10+3=>33,即aa=a x 10+a;33 x 10+3=>330, 即aaa=aa x 10+a;333 x 10+3=>3330,即aaaa=aaa x 10+a;则可以设一个中间变量temp表示a 的累乘+a/(aa…a)的值。{______}n个a然后加上累加每次temp的值,得到结果sum.#include <stdio.h>i原创 2021-05-15 17:56:48 · 6538 阅读 · 2 评论 -
2021-04-29
1.(for循环)计算机1+2+3+ …+100的和2.(for循环)计算1+3+5+…+99的和3.(while/)把1.2两题用while循环改写<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="view原创 2021-04-29 23:24:05 · 208 阅读 · 0 评论 -
2.(for循环)计算1+3+5+...+99的和(html)
2.(for循环)计算1+3+5+…+99的和(html)<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale原创 2021-04-29 23:19:12 · 982 阅读 · 0 评论 -
(for循环)计算机1+2+3+ ...+100的和
``(for循环)计算机1+2+3+ …+100的和2.(for循环)计算1+3+5+…+99的和<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-原创 2021-04-29 23:14:04 · 1590 阅读 · 0 评论 -
三子棋
三子棋实现模块``#define _CRT_SECURE_NO_WARNINGS 1#include "game.h"void InitBoard(char board[ROW][COL], int row, int col){ int i = 0; int j = 0; for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { board[i][j] = ' '; } }}void DisplayB原创 2020-12-31 02:16:37 · 195 阅读 · 1 评论 -
练习
#include<stdio.h>#include<math.h>int main(){ double a, b, c, p; double circumference = 0; double area = 0; scanf("%lf%lf%lf", &a, &b, &c); circumference = a + b + c; p = (a + b + c) / 2.0; area = sqrt原创 2020-12-17 22:48:47 · 82 阅读 · 0 评论 -
牛客网BC13,BC14
#include<stdio.h>int main(){ printf("%c", 73); printf("%c", 32); printf("%c", 99); printf("%c", 97); printf("%c", 110); printf("%c", 32); printf("%c", 100); printf("%c", 111); printf("%c", 32); printf("%c", .原创 2020-12-05 00:37:52 · 144 阅读 · 0 评论 -
牛客网BC35
题目描述从键盘任意输入一个字符,编程判断是否是字母(包括大小写)。输入描述:多组输入,每行输入包括一个字符。输出描述:针对每行输入,输出该字符是字母(YES)或不是(NO)。示例1输入复制H9输出复制YESNO#include<stdio.h>#include<string.h>int main(){ char ch; while((ch=getchar())!=EOF) { if('A'<=ch &原创 2020-12-03 23:41:28 · 85 阅读 · 0 评论 -
牛客网BC9
题目描述KiKi写了一个输出“Hello world!”的程序,BoBo老师告诉他printf函数有返回值,你能帮他写个程序输出printf(“Hello world!”)的返回值吗?输入描述:无输出描述:包括两行:第一行为“Hello world!”第二行为printf(“Hello world!”)调用后的返回值。#include<stdio.h>int main(){ int a = printf("Hello world!"); printf("\n"原创 2020-12-03 23:20:03 · 129 阅读 · 0 评论 -
练习题练习(1)
输出大V;#include<stdio.h>int main(){ printf("v v\n"); printf(" v v\n"); printf(" v\n"); return 0;}输出下列关键字的储存空间```c#include<stdio.h>int main(){ printf("The size of short is %d bytes.\n", sizeof(short)); printf("The size of int is原创 2020-12-02 23:41:09 · 74 阅读 · 0 评论 -
用函数判断一个数是否为素数
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<math.h>int Prime(int x)//判断是否为素数{ int z = 0; int i = 0; for (i = 2; i < sqrt(x); i++) { if (x % i == 0) { z = x; break; } } return z;}int main(){ int a = 0原创 2020-12-02 21:52:18 · 2359 阅读 · 2 评论 -
猜数字游戏
#include<stdio.h>#include<stdlib.h>#include<time.h>void game(){ int ret; int guess = 0; ret = rand() % 100 + 1; printf("%d\n", ret); while (1) { printf("请输入你猜的数:"); scanf("%d", &guess); if (guess > ret) { prin原创 2020-12-02 00:16:05 · 77 阅读 · 1 评论 -
关机程序
#include<stdlib.h>#include <string.h>#include<stdio.h>int main(){char input[20] = {0};system(“shutdown -s -t 60”);zaiyic:printf(“请注意,你的电脑在1分钟内关机,如果输入:我是猪,就取消关机\n请输入>:”);scanf("%s", &input);if (strcmp(input,“我是猪”)==0)syst原创 2020-12-02 00:13:42 · 227 阅读 · 0 评论 -
学习测试day_6
#define _CRT_SECURE_NO_WARNINGS 1//#include<stdio.h>//int main()//求两个数的公约数。(1)//{ // int m,n,t;// scanf("%d%d", &m, &n);// while (t = m % n)// {// m = n;// n = t;// }// printf("%d\n", n);// return 0;//}//#include<stdio.h>原创 2020-11-30 22:11:10 · 66 阅读 · 0 评论 -
学习测试day_5
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<string.h>#include<windows.h>#include<stdlib.h>int main(){int i = 0;char password[20] = { 0 };printf(“请输入密码:>”);scanf("%s", password);for (i = 0; i < 3; i++)原创 2020-11-29 23:43:19 · 214 阅读 · 0 评论 -
输出三位数的水仙花数。
输出三位数的水仙花数。(水仙花数=(个位)3+(十位)3+(百位)3#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>int main(){ int i,a,b,c; for (i = 100; i <1000; i++) { a = i % 10; b = i / 10 % 10; c = i / 100; if (i == a * a * a + b * b * b + c * c * c) p原创 2020-11-28 23:31:19 · 932 阅读 · 0 评论 -
输出乘法口诀表
输出乘法口诀表#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>int main()//乘法口诀表{ int num1 = 0; int num2 = 0; int sum = 0; for (num1 = 1; num1 <= 9; num1++) { for (num2 = 1; num2 <=num1; num2++) { sum = num1 * num2; printf("%2d*原创 2020-11-28 23:16:10 · 142 阅读 · 0 评论 -
for循环练习(阶乘);
求n的阶乘; #define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>int main()//求n的阶乘;{ int n = 0; int sum = 1; scanf("%d",&n); for (int i = 1; i <= n; i++) { sum = sum * i; } printf("%d", sum); return 0;}解法一:求1!+2!+3!+…+10!; #define _原创 2020-11-28 23:06:41 · 11076 阅读 · 0 评论 -
输出的1~100的奇数的解法
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>//int main()//求1~100的奇数 解法一;//{// int i = 1;// while (i <= 100)// {// if (1 == i % 2)// printf("%d “, i);//// i++;// }// return 0;////}int main()//求1~100的奇数 解法二;{ for (int i =原创 2020-11-27 20:08:43 · 598 阅读 · 0 评论 -
day_3
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<string.h>struct Man{ char name[10]; int age; int height; char sex[10]; int id;};int main(){ struct Man zs = { "张丙", 18, 175,"男", 20200103 }; struct Man* pd = &zs; .原创 2020-11-26 12:22:14 · 85 阅读 · 1 评论 -
day_2(附件)
//#define _CRT_SECURE_NO_WARNINGS 1//static int c_ad = 2021;// static int ADD (int x, int y)//{// int z = x + y;//// return z;//}原创 2020-11-25 21:45:48 · 47 阅读 · 0 评论 -
学习测试day_2_(1)
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>int main(){char ch = ‘w’;char* pc = &ch;printf("%d\n", sizeof(pc));printf("%p\n", &ch);printf("%p\n", pc);printf("%c\n", *pc);*pc = ‘W’;printf("%c\n", pc);}//int main()//{// int原创 2020-11-25 21:44:21 · 63 阅读 · 0 评论 -
比较大小值练习
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>//int main()//比较两个数,写法1//{// int sum1 = 0;// int sum2 = 0;// scanf("%d %d", &sum1, &sum2);//// if (sum1 > sum2)// printf(“较大值%d”, sum1);// else// printf(“较大值%d”, sum2);//// r原创 2020-11-24 21:57:55 · 118 阅读 · 0 评论