c语言
五十六朵花
一个c++爱好者
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++:连续出现的字符
题目描述给定一个字符串,在字符串中找到第一个连续出现至少k次的字符。输入第一行包含一个正整数k,表示至少需要连续出现的次数。1 ≤ k ≤ 1000。第二行包含需要查找的字符串。字符串长度在1到2500之间,且不包含任何空格符。输出若存在连续出现至少k次的字符,输出该字符;否则输出No。样例输入Copy3abcccaaab样例输出Copyc#include <bits/stdc++.h>using namespace std; i...原创 2022-02-26 21:31:30 · 3991 阅读 · 1 评论 -
C++:压缩算法2.0
题目描述某压缩算法的基本思想是用一个数值和一个字符代替具有相同值的连续字符。若是单个字符则不进行压缩,直接输出。例如,输入字符串"RRRRRGGBBBBBBC",压缩后为“5R2G6BC”。请编写程序实现上述功能。输入输入共一行,一串待压缩的字符。输出输出共一行,压缩后的一串字符。样例输入CopyRRRRRGGBBBBBBC样例输出Copy5R2G6BC提示输入的字符个数在100个以内,字符串中不含空格。#include <bits/std...原创 2022-02-26 21:27:39 · 1104 阅读 · 0 评论 -
C#:R进制转换
题目描述•变式二:(R进制转换-题2)将十进制数n转化为R进制数。输入•输入两行:•第一行为十进制整数n(n范围为1~2^31)•第二行为需要转化的进制R(R范围为2~16)输出•输出一行,为其R进制数。样例输入Copy2616样例输出 Copy1A#include<bits/stdc++.h>using namespace std;int main(){ int n,r,i; while(scanf("%d %..原创 2021-11-17 16:30:09 · 401 阅读 · 0 评论 -
C#:打印ASCII码
题目描述张三知道每个字符的 ASCII 码,但是他想考考你!输入一个除空格以外的可见字符(保证在函数`scanf`中可使用格式说明符`%c`读入),输出其 ASCII 码。输入一个可见字符。输出一个十进制整数,即该字符的 ASCII 码。样例输入CopyA样例输出Copy65提示每个字符都对应着一个数字,那个数字就是它的ASCII码,电脑中就是把这个数字以二进制的形式进行存储的。方法一:强制类型转换 cout<<int(a); /...原创 2021-10-24 12:53:09 · 3184 阅读 · 0 评论 -
连续输出hello
题目描述输出10个“hello”,每行一个。输出hellohellohellohellohellohellohellohellohellohello样例输出Copyhellohellohellohellohellohellohellohellohellohello#include<bits/stdc++.h>using namespace std; int main(){ for (int i=1; i..原创 2021-10-10 10:59:31 · 433 阅读 · 0 评论 -
最高分数的学生姓名
题目描述输入学生的人数,然后再输入每位学生的分数和姓名,求获得最高分数的学生的姓名。输入第一行输入一个正整数N(N ≤ 100),表示学生人数。接着输入N行,每行格式如下: 分数 姓名分数是一个非负整数,且小于等于100;姓名为一个连续的字符串,中间没有空格,长度不超过20。数据保证最高分只有一位同学。输出获得最高分数同学的姓名。样例输入Copy587 lilei99 hanmeimei97 lily96 lucy77 jim样例输出Co...原创 2021-10-10 10:55:40 · 319 阅读 · 0 评论 -
判断字符串是否为回文
题目描述输入一个字符串,输出该字符串是否回文。回文是指顺读和倒读都一样的字符串。输入输入为一行字符串(字符串中没有空白字符,字符串长度不超过100)。输出如果字符串是回文,输出yes;否则,输出no。样例输入Copyabcdedcba样例输出Copyyes#include <bits/stdc++.h>int main(){char a[100];int i=0,j=0;gets(a);while(a[i]!='\0')i++;...原创 2021-10-07 14:39:08 · 1194 阅读 · 0 评论 -
简单C#编程:a+b
#include <stdio.h>int main(){ int a,b; while(scanf("%d %d",&a, &b) != EOF) printf("%d\n",a+b); return 0;}原创 2021-10-07 14:12:50 · 563 阅读 · 0 评论 -
1263: 流感传染(信息一本通)
样例输入Copy5....#.#.@..#@..#.........4样例输出Copy16//Date:July 24,2017//Writen by Yuxin Liu#include <iostream>using namespace std;int main(){ //输入n和相应的房间状态 int n=0; cin >> n; char a[50][50]; for (int i...原创 2021-10-03 14:39:28 · 188 阅读 · 1 评论 -
字符串逆序
题目描述输入一串以‘!’结束的字符,按逆序输出。样例输入abc!样例输出cba#include <iostream> #include <cstdio>using namespace std;char ch[10000]; void gth(int i) { if (ch[i] != '!') { gth(i+1); } else { return; } printf("%..原创 2021-10-02 10:53:30 · 1013 阅读 · 1 评论 -
简单编程:字符三角形
样例输入:*样例输出: *********#include<bits/stdc++.h>//万内库 using namespace std;int main(){ char a;//char是存入字符变量,注意,不要用int cin>>a;//输入字符a cout<<" "<<a<<endl; cout<<" "<<a<<a<<a<<...原创 2021-09-24 19:32:16 · 698 阅读 · 0 评论 -
小鸟快飞1.0
#include<stdio.h>#include<stdlib.h>#include<conio.h>#include<time.h>//可以直接用#include<bits/stdc++.h>#include<Windows.h>int Grade = 1, Score = 0, Max_blank = 9, Distance = 18;struct Birds{int x; int y;}; Birds *Bir.原创 2021-09-22 19:28:19 · 252 阅读 · 0 评论 -
学生打卡统计
#define _CRT_SECURE_NO_WARNINGS 1#include <bits/stdc++.h>FILE *fp; char a; float kq = 10; struct student{ char name[10]; char number[11]; char sex; int year; int month; int day; .原创 2021-09-22 19:21:57 · 302 阅读 · 1 评论 -
电阻的阻值
题目的描述:对于两个电阻,其电阻值分别为r1和r2。若将它们并联,其阻值变为:1/(1/r1+1/r2)。输入两个电阻的阻值大小,浮点型。输出并联之后的阻值大小,结果保留2位小数。输入:两个电阻阻值大小,浮点型,以一个空格分开。输出:出并联之后的阻值大小,结果保留2位小数。样例输入Copy3 4样例输出Copy1.71#include<iostream>#include<cstdio>//两条可以合并成#includ...原创 2021-09-19 21:20:05 · 191 阅读 · 0 评论 -
两个数的余数和商
样例输入:5 3样例输出:2 1.67#include<bits/stdc++.h> //也可以用#include<cstdio> using namespace std; int main() { int a,b; scanf("%d %d",&a,&b); printf("%d %0.2lf",a%b,a*1.0/b*1.0); return 0; } ...原创 2021-09-19 21:11:24 · 213 阅读 · 0 评论 -
1~n的数求和
#include<bits/stdc++.h>using namespace std;int main(){ int n,i; int sum=0; scanf("%d",&n); for(i=0;i<=n;i++) { sum=sum+i; } printf("%d",sum); return 0;}原创 2021-09-16 20:08:18 · 1436 阅读 · 0 评论 -
阶乘的运算
#include <bits/stdc++.h>using namespace std; int main(){ unsigned int n; unsigned long long factorial = 1; cin >> n; for(int i = 1; i <=n; ++i) { factorial *= i; } cout << factorial; .原创 2021-09-16 20:05:07 · 134 阅读 · 0 评论 -
吃豆人模型
#include <math.h>#include <stdio.h> int main() { double x, y; for (y = 1; y >= -1; y -= 0.05, putchar('\n')) for (x = -1; x <= 1; x += 0.025) putchar(" *"[ x * x + y * y < 1 &...原创 2021-09-12 10:33:07 · 217 阅读 · 2 评论
分享