三九宝宝网宝宝教育教学论文

C语言输出10个数中出现次数最多的数字及其次数

02月22日 编辑 39baobao.com

[c语言创建一个储存10个数字的链表并倒序输出]#include #include struct node { int a; node *next; }; void output(node *p) { if (p != NULL) { output(p->next); printf ("%d ", p->a); } } int main() { int a, n; no...+阅读

#include

#include

#include

int main()

{

int a[10];//每个数字的计数器

int num;

int i;

char ch[100],*ch1,num1;

for(i = 0;i < 10;i++)

a[i] = 0;

printf("请输入一个整数:");

scanf("%d",&num);

itoa(num,ch,10); //将数字转化为字符串

for(ch1 = ch;ch1

{

num1 = *ch1;

switch(num1)

{

case '0': a[0]++; break;

case '1': a[1]++; break;

case '2': a[2]++; break;

case '3': a[3]++; break;

case '4': a[4]++; break;

case '5': a[5]++; break;

case '6': a[6]++; break;

case '7': a[7]++; break;

case '8': a[8]++; break;

case '9': a[9]++; break;

default:break;

}

}

printf("各数字出现的次数如下:\n");

printf("数字:0 1 2 3 4 5 6 7 8 9\n");

printf("次数:");

for(i = 0;i < 10;i++)

printf("%-3d",a[i]);

printf("\n");

return 0;

}

以下为关联文档:

C语言创建一个存储10个数字的链表并倒序输出我这里有个热乎的C++用类实现的,功能很齐全,在VS2010很好运行,C版本的目前没有,笔记本上貌似,你先看行不行,直接把代码上去就可以了。请采纳。#include using namespace std; type...

C语言用调用函数逆序输出10个数代码里有一些问题,看注释。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include<stdio.h> intnixu (intn,inta[]); voidmain() { inta[10],i; printf("pl...

c语言输出三个数的最大值#includeint main { int max(int x,int y,int z); int a,b,c,d; scanf("%d%d%d",&a,&b,&c); d=max(a,b,c); printf("the max is %d\n",d);//这里缺少个%d } int max(int x,int y,...

C语言中输入三个数如何输出其最大值#include "pch.h" #include int main() { int a, b, c, max; max = 0; printf("请输入3个数:"); scanf_s("%d %d %d", &a, &b, &c); if (a > max) { max = a; } if (b > max) { max =...

c语言输入三个数输出其中的最大值1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 # include <stdio.h> intmain() { inta,b,c,max; printf("please input a,b,c:\n"); scanf("%d,%d,%d",&a,&b,&c); if((a>=b)...

初学者:C语言如何输出三个数中最大数#include<stdio.h> int main() { int a,b,c,d; a=1,b=2,c=3; printf("%d,%d,%d",a,b,c); if(a>=b)d=a; else d=b; printf("三个数中最大数是:"); if(d>c) printf("%d",d); else printf...

c语言整数个数的输出与逆序输出原数这样你还不如用char来做。 #include<stdio.h> int main() { char a,b,c,d,e; scanf("%c%c%c%c%c\n",&a,&b,&c,&d,&e); if('0'<a & a>='9' & '0'<b & b>='9' & '0'<c &...

C语言逆向输出数字#include "stdio.h" int main() { int n,i,j,a; scanf("%d",&n); if(n%2==1)//如果输入的是奇数 { for(i=0;i<4;i++) //输出是4行 { for(j=0;j<=i;j++) //每行输出i+1个数 { pri...

C语言实现冒泡排序选择排序插入排序及其移动次数你说的排序我给你源代码,在代码里面简单的说了一下算法思想。如果是要学习,我建议去看书和看别人的博客,明白排序的思想,只有明白了算法的思想,才能轻易的看懂排序的代码。我的代...

推荐阅读
图文推荐