简单的素数判断C程序
仅供学习使用:
/*********************************************
* Name : prime.c
* Purpose : prime (素数判断)
* Author : zimo
* Date : 01/21/2010
* ******************************************/
#include<stdio.h>
int main()
{
int m , n ;
printf("Enter a number: ");
scanf("%d",&n);
for (m = 2 ;m < n ;m++)
if (n % m ==0)
break;
if (m < n)
printf("%d is divisble by %d \n", n , m);
else
printf("%d is prime. \n",n);
return 0;
}
相关文档:
#include <assert.h> //设定插入点
#include <ctype.h> //字符处理
#include <errno.h> //定义错误码
#include <float.h> //浮点数处理
#include <fstream.h> //文件输入/输出
#include <iomanip.h> //参数化输入/输出
#include & ......
Google Android开发博客今天宣布,即日起开放针对Android平台的原生软件开发SDK下载。由于在SDK前面又加上了原生二字,即Native Development Kit,因此又被Google称为NDK。在此之前,Android平台的第三方应用程序均是依靠基于Java的Dalvik特制虚拟机进行开发的。原生 SDK的公布可以让开发者更加直接的接触Android系统资源, ......
#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;
int main(void)
{
FILE *fp, *fp2;
char buf[1024*300];
fp = fopen("in.txt", "rb");
fp2 = fopen("out.txt", "wb+");
fseek(fp, 0, SEEK_END);
int iLen ......
函数名: stpcpy
功 能: 拷贝一个字符串到另一个
用 法: char *stpcpy(char *destin, char *source);
程序例:
#include <stdio.h>
#include <string.h>
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
stpcpy(string, str1);
& ......
找错题
试题1:
void test1()
{
char string[10];
char* str1 = "0123456789";
strcpy( string, str1 );
}
试题2:
void test2()
{
char string[10], str1[10];
int i;
for(i=0; i<10; i++)
{
str1[i] = 'a';
}
strcpy( string, str1 );
}
试题3:
void test3( ......