摘要:
嘿嘿。。。 阅读全文
posted @ 2014-01-07 20:47
温婉若妖
阅读(127)
评论(1)
推荐(0)
|
摘要:
1 #include "stdafx.h" 2 #include 3 using namespace std; 4 int main() 5 { 6 int l,m,n,i; 7 for( i=100;i<1000;i++) 8 { 9 n=i%10; //个位数10 l=(i/100);//百位数11 m=(i/10)%10;//十位数12 if(i==n*n*n+m*m*m+l*l*l)13 {14 printf("%d",i);15 ... 阅读全文
posted @ 2014-01-06 02:56
温婉若妖
阅读(565)
评论(0)
推荐(0)
摘要:
1 #include "stdafx.h" 2 #include 3 #include 4 int main() 5 { 6 double a=1,b=1; 7 double s=0; 8 int i,n; 9 scanf("%d",&n);10 //循环 从1加到n 即n次11 for(i=1;i<=n;i++)12 {13 //后一项的分子等于前一项的分子加分母14 a+=b;15 s+=a/b;16 //a b的数据互换一下17 double t;... 阅读全文
posted @ 2014-01-04 21:05
温婉若妖
阅读(158)
评论(0)
推荐(0)
摘要:
1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 int _tmain(int argc, _TCHAR* argv[]) 6 { 7 string a,b; 8 printf("输入两个数:"); 9 scanf("%c,%c",&a,&b);10 for(int i=0;i<a.length()-b.length();i++)11 {12 if(b==a.substr(i,b.length()))13 {14 ... 阅读全文
posted @ 2014-01-03 02:46
温婉若妖
阅读(228)
评论(0)
推荐(0)
摘要:
1 #include "stdafx.h" 2 #include 3 4 int _tmain(int argc, _TCHAR* argv[]) 5 { 6 int n;int k;int c=0; 7 printf("请输入2个数:"); 8 scanf("%d,%d",&n,&k); 9 if(n==2)10 {11 n++12 }13 if (n==3)14 {15 n+1;16 ... 阅读全文
posted @ 2013-12-30 22:26
温婉若妖
阅读(333)
评论(0)
推荐(0)
摘要:
1 // sf4.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include 6 using namespace std; 7 int _tmain(int argc, _TCHAR* argv[]) 8 { 9 int n,k,a[30];10 int i=0;11 printf("输入两个数字:");12 scanf("%d,%d",&n,&k);13 //先做判断n k的大小14 if(n=0;i--)42 {43 printf("%d&qu 阅读全文
posted @ 2013-12-27 01:23
温婉若妖
阅读(172)
评论(0)
推荐(0)
摘要:
1 int n; 2 printf("请输入一个数:"); 3 scanf("%d",&n); 4 for(int i = 2;i*i < n;i++) 5 { 6 if(num % i == 0) 7 { 8 printf("%d不是一个素数",num); 9 system("pause");10 return 0;11 }12 }13 printf("%d是一个素数",num);14 ... 阅读全文
posted @ 2013-12-25 21:58
温婉若妖
阅读(130)
评论(0)
推荐(0)
摘要:
n为奇数 (n=3,5,7,9,11……) (n=2*k+1,k=1,2,3,4,5……)奇数阶幻方最经典的填法是罗伯特法(也有人称之为楼梯方)。填写方法是这样:把1(或最小的数)放在第一行正中; 按以下规律排列剩下的n*n-1个数:(1)、每一个数放在前一个数的右上一格;(2)、如果这个数所要放的格已经超出了顶行那么就把它放在底行,仍然要放在右一列;(3)、如果这个数所要放的格已经超出了最右列那么就把它放在最左列,仍然要放在上一行;(4)、如果这个数所要放的格已经超出了顶行且超出了最右列,那么就把它放在前一个数的下一行同一列的格内;(5)、如果这个数所要放的格已经有数填入,处理方法同(4)。 阅读全文
posted @ 2013-12-24 16:28
温婉若妖
阅读(293)
评论(0)
推荐(0)
摘要:
#include "stdafx.h"#includeint _tmain(int argc, _TCHAR* argv[]){ //i行号 j列 n为边长 int i,j,n; printf("输入:"); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=n+i-1;j++) if((j==n-i+1)||(j==n-1+i)) printf("*"); else printf(" "); ... 阅读全文
posted @ 2013-12-23 22:21
温婉若妖
阅读(388)
评论(0)
推荐(0)
|