周期串
//周期串 例:hahahahahahaha,周期为2.其中长度必为周期的倍数 [cpp] #include …
//周期串 例:hahahahahahaha,周期为2.其中长度必为周期的倍数 [cpp] #include …
最大公约数的几种求法: 1.方法一利用循环求出最大公约数,效率最慢 [cpp] #include <io…
数组做参数时将退化成指针,大家看程序: #include “iostream” #in…
南阳理工学院10级数据结构实验代码(by 岳): (线性表应用,栈和队列的应用,二叉树的应用,图论及其应用,查…
批处理简单实现数字雨效果,代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
@echo off setlocal ENABLEDELAYEDEXPANSION color 02 for /l %%i in (1,1,80) do ( set Down%%i=0 ) for /l %%i in (0) do ( set line= for /l %%j in (1,1,80) do ( set /a Down%%j-=1 call set x=!down%%j! if !x! LSS 0 ( set /a Arrow%%j=!random!%%6 set /a Down%%j=!random!%%15+10 ) call set x=!Arrow%%j! if "!x!" == "1" ( set line=!line!1 ) else (set "line=!line! ") ) call set /p=!line! |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
One-atoi:<stdlib.h> /*atoi example*/ #include <stdio.h> #include <stdlib.h> int main () { int i; char szInput [256]; printf ("Enter a number: "); fgets ( szInput, 256, stdin ); i = atoi (szInput); printf ("The value entered is %d. The double is %d.\n",i,i*2); return 0; } Two-itoa:<stdlib.h> // itoa example #include <stdio.h> #include <stdlib.h> int main () { int i; char buffer [33]; printf ("Enter a number: "); scanf ("%d",&i); itoa (i,buffer,10); printf ("decimal: %s\n",buffer); itoa (i,buffer,16); printf ("hexadecimal: %s\n",buffer); itoa (i,buffer,2); printf ("binary: %s\n",buffer); return 0; } Three-char->string&&string->char: #include <iostream> #include <string> using namespace std; int main() { string x,temp; char p[15]="i am a boy!"; cin>>x; cout<<x.c_str()<<endl; temp=p; cout<<temp<<endl; return 0; } Four-sprintf(Formatted data to writing a string)<stdio.h> #include <iostream> #include <stdio.h> using namespace std; int main() { char str[20]; sprintf(str,"%d",168); cout<<str<<endl; sprintf(str,"��",123,457); cout<<"Specified width"<<str<<endl; sprintf(str,"%8x",123); cout<<"width+hexadecimal"<<str<<endl; return 0; } Five-ceil(返回大于或者等于指定表达式的最小整数) // ceil example #include <stdio.h> #include <math.h> int main () { printf ("ceil of 2.3 is %.1lf\n", ceil (2.3) ); printf ("ceil of 3.8 is %.1lf\n", ceil (3.8) ); printf ("ceil of -2.3 is %.1lf\n", ceil (-2.3) ); printf ("ceil of -3.8 is %.1lf\n", ceil (-3.8) ); return 0; } Output: ceil of 2.3 is 3.0 ceil of 3.8 is 4.0 ceil of -2.3 is -2.0 ceil of -3.8 is -3.0 |