void ip2s(int n)
{
unsigned char *p = &n;
printf(“%u.%u.%u.%u\n”, *p, *(p + 1), *(p + 2), *(p + 3));
}
int main()
{
int ip=0;
unsigned char *p1=&ip;
int a=0x123……继续阅读 »
9年前 (2016-04-10) 1085浏览
0个赞
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//多项式链表结点类型定义
typedef struct {
float coef; //系数
int expn; //指数
}DataType;
typedef struct node {
DataType d……继续阅读 »
9年前 (2016-04-10) 1315浏览
0个赞
这是一个求组合数的代码
能正常运行
#include <stdio.h>
#include <stdlib.h>
#define MAXN 100
int a[MAXN]= {0};
int counts=0;
void combine(int m,int k)
{
int i,j;
for (i=m; i>=……继续阅读 »
9年前 (2016-04-10) 1124浏览
0个赞
for循环求平均数 为什么会跳过里面的if检查输入一个数后就变这样了
解决方案
20
引用:
for循环求平均数 为什么会跳过里面的if检查输入一个数后就变这样了
输入数字后你又输入了回车,回车被下个scanf 取走了.
你在下面scanf 的%c 前面加一个空格就好了。这个空格有去除回车的作用
scanf(” %c”,&a……继续阅读 »
9年前 (2016-04-10) 970浏览
0个赞
#include <stdio.h>
main(){
char string1[80],string2[1]; //定义两个字符
int i;
char c;
printf(“请输入需要加密的字符串:\n”);
while(c=getcher()!=”\n”);{ //当输入的字符……继续阅读 »
9年前 (2016-04-10) 2018浏览
1个赞
int Del_book(BOOK * Head)
{
BOOK * head=Head->pNext;//Head指向头结点,head指向第一个结点
BOOK *temp;//存放要删除的结点
int pos;
int i;
if (Empty_book(Head))
{
printf(“链表为空\n”);
return fa……继续阅读 »
9年前 (2016-04-10) 1235浏览
0个赞
已知某一整数,求各位数字均为素数,而且各位数字之和也为素数,例如232,2+3+2=7也是素数。用c语言这样做为什么错了
#include<stdio.h>
fun(int n)
{
int k,r;
for(k=1;k<n-1;k++)
{r=n%k;
if(r==0) break;}
if(k==n)
return 1;
else
re……继续阅读 »
9年前 (2016-04-10) 1020浏览
0个赞
问一下有没有一种效率很高的从一堆有重复字符串出现的字符串数组中记录下每个字符串重复出现的次数的算法?
解决方案
5
用二叉树,记录就可以了
或用hash table
5
hash也可以,但索引项为字符串的hash table本人构造比较困难
可以考虑直接采用标准库里的map容器,它是用红黑树实现的,效率应该和hash有一拼
10
http://baike.b……继续阅读 »
9年前 (2016-04-10) 863浏览
0个赞
编写程序,统计1-100,阿拉伯数字“5”出现的次数
解决方案
40
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
int x=0;
for(int i=1;i<=100;i++)
{
int a=i%10;……继续阅读 »
9年前 (2016-04-10) 1560浏览
0个赞