#include <stdio.h> #include <string.h> /*此题只需要删除单个字符,比较简单.相信大家也能做出来的.我这个也是可以实现的.只是加了两个判断如果需要删除特定的"字串".下面的程序就可以实现. 编写程序:输入一个字符串,将此字符串中特定的字符删去后, 显示新的字符串,要求用函数来完成删去字符的操作. */ del_string(char *str,char *sub){ int i,j,k=0; char newstr[30];…
[C语言]输入一个整数N,求N以内的素数之和 /* ============================================================================ Name : HelloWorld.c Author : Firesun Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style =======================…
package com.swift; public class String_To_Integer_Test { public static void main(String[] args) { /* * 编程求字符串“100”和“150”按十进制数值做差后的结果以字符串形式输出. */ String str1="100"; String str2="150"; int i1=Integer.valueOf(str1); int i2=Integer.valueOf…
题目: 输入一个多位的数字,12345,求各位相加1+2+3+4+5=15(10分)题目内容: 输入一个多位的数字,1求各数位相加. 例如输入12345,则计算1+2+3+4+5=15 输入格式: 一个整数 输出格式: 一个整数 输入样例: 1234567890 输出样例: 45 编码: #include<stdio.h> int main() { int n,i,tmp,ret=0; scanf("%d",&n); while(n!=0) { tmp=n%10;…
//旋转数组的最小数字 //题目:把一个数组最開始的若干个元素搬到数组的末尾.我们称之为数组的旋转. //输入一个递增排序的数组的一个旋转.输出旋转数组中的最小元素. //比如:数组{3.4,5,1,2}为{1,2.3.4.5}的一个旋转,最小元素是1. #include <stdio.h> #include <assert.h> int min_equ(int *src, int left, int right) { int i = 0; int ret = src[left];…
分析: 三种类型, A.2月比较特殊,平年的2月只有28天,而闰年的2月有 29 天: B.4.6.9.11月: C.其他1.3.5.7.8.10.12月. 代码: /*输入一个年份和月份,输出该月的天数*/ #include<stdio.h> int main() { int year, month; printf("输入年和月(用空格分隔):\n"); scanf_s("%d %d", &year, &month); switch (…
素数的定义: 素数(prime number)又称质数,有无限个. 素数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数,这样的数称为素数.代码1: #include<stdio.h> int main() { int m, n; printf("请输入一个正整数:\n"); scanf_s("%d", &m); ; n < m - ; n = n + ) ) break; if (n < m) printf("%…
// 题目:统计一个数字在排序数组中出现的次数. //  比如:排序数组{1.2,3,3,3,3,4.5}和数字3,因为3出现了4次.因此输出4 有一种最简单的算法,遍历.可是有比它效率更高的 先看遍历: #include <stdio.h> #include <assert.h> int num_time(int *arr, int len, int a) { int i = 0; int count = 0; assert(arr != NULL); for (; i <…
#include<stdio.h> int main() { ]; ; printf("请输入一串字符:"); gets_s(a); ; a[i] != '\0'; i++)/*找出单词个数*/ { if (a[i] == ' ') j += ; } printf("单词个数:%d\n", j); ] >= ] <= 'z')/*判断首字母大小写并转换*/ a[] -= ; ; a[i] != ; i++) { printf("%c…
#include <stdio.h> #include<string.h> int main() { ]; int i,j,k,len; gets_s(a); len= strlen(a);/*计数器:遇到'\0'停止并返回计数器值*/ ;i<len/;i++) ;j<len-;j+=) ]) { k = a[i]; a[i] = a[i + ]; a[i + ] = k; } ; i < len; i++) printf("%3c", a[i…