Welcome![Sign In][Sign Up]
Location:
Search - count.j

Search list

[Mathimatics-Numerical algorithmsc program6.rar

Description: 三色球问题 若有一个口袋放有12个球,其中有3个红的,3个白的和6个黑的,从中任取8个球, 问共 这也是一个可用穷举法求解的问题。 设任取的红球个数为i, 白球个数为 j,则黑球个数为8-i-j,用count统计不同的搭配数目
Platform: | Size: 249 | Author: | Hits:

[Other用c编写的N*N的螺旋矩阵源代码

Description:

/*
实现效果:
1 2 6 7 15
3 5 8 14 16
4 9 13 17 22
10 12 18 21 23
11 19 20 24 25
*/
#include <stdio.h>
#define N 5 //阶数,即N*N的螺旋矩阵

void main()
{
    int i, j, num=1, a[N][N];
    for(i=0; i<=N/2; i++)
    {
        for(j=i; j<N-i; j++) a[i][j]=n++;
        for(j=i+1; j<N-i; j++) a[j][N-i-1]=n++;
        for(j=N-i-2; j>i; j--) a[N-i-1][j]=n++;
        for(j=N-i-1; j>i; j--) a[j][i]=n++;
    }
    for(i=0; i<N; i++)
    {
        for(j=0; j<N; j++)
            printf("%2d ",a[i][j]);
        printf("\n");
    }
}
    

 

不知道叫什么,先叫它“回宫图”吧
年初的时候在贴吧瞎逛,看到了一个程序挺有意思,会输出如下的形状:
01 24 23 22 21 20 19
02 25 40 39 38 37 18
03 26 41 48 47 36 17
04 27 42 49 46 35 16
05 28 43 44 45 34 15
06 29 30 31 32 33 14
07 08 09 10 11 12 13
仔细看这个形状,数字是按顺序往里回旋的,觉得很有创意,可是一看源代码头就大了,
每个编程人都知道看别人的代码是很困难的,尤其像这种不知道思路的,所以也就放下
没管了。
昨天上物理课实在是没心思听,就想起这个程序,想了一节课,果然不负有心人,给弄出来了,这个是增强版的,可以输入1-10中的任意个数,然后生成图形。
先看代码,没有注释,所以不好看的懂。
#include<stdio.h>
main()
{
       int n,m,i,j,t,k=1;
       int a[11][11];
       clrscr();
       do{
       printf("please input a number(1-10):");
       scanf("%d",&n);
       }while(n<1||n>10);
       t=n+1;
       for(m=1;m<=t/2;m++)
         {
           for(i=m;i<=t-m;i++)
             {a[i][m]=k;k++;}
           for(j=m+1;j<=t-m;j++)
             {a[i-1][j]=k;k++;}
           for(i=n-m;i>=m;i--)
             {a[i][j-1]=k;k++;}
           for(j=n-m;j>=m+1;j--)
             {a[i+1][j]=k;k++;}
         }
       for(i=1;i<=n;i++)
         {
           for(j=1;j<=n;j++)
             {
               if(a[i][j]<=9) printf("0%d ",a[i][j]);
               else printf("%d ",a[i][j]);       }
           printf("\n");
         }
       getch();
}
就是这样的。


可以更简洁些:

#include<stdio.h>
main()
{
       int n,m,i,j,t,k=1;
       int a[11][11];
       clrscr();
       do{
       printf("please input a number(1-10):");
       scanf("%d",&n);
       }while(n<1||n>10);
       t=n+1;
       for(m=1;m<=t/2;m++)
         {
           for(i=m;i<=t-m;i++)
             a[i][m]=k++;
           for(j=m+1;j<=t-m;j++)
             a[i-1][j]=k++;
           for(i=n-m;i>=m;i--)
             a[i][j-1]=k++;
           for(j=n-m;j>=m+1;j--)
             a[i+1][j]=k++;
         }
       for(i=1;i<=n;i++)
         {
           for(j=1;j<=n;j++)
             {
               if(a[i][j]<=9) printf("0%d ",a[i][j]);
               else printf("%d ",a[i][j]);       }
           printf("\n");
         }
       getch();
}

 


 #include <stdio.h>
#define N 8
main(){
 int i,j,n=1,a[N][N];
 for(i=0;i<=N/2;i++){
  for(j=i;j<N-i;j++)
   a[i][j]=n++;
  for(j=i+1;j<N-i;j++)
   a[j][N-i-1]=n++;
  for(j=N-i-2;j>i;j--)
   a[N-i-1][j]=n++;
  for(j=N-i-1;j>i;j--)
   a[j][i]=n++;
 }
 for(i=0;i<N;i++){
  printf("\n\n");
  for(j=0;j<N;j++)
   printf("%5d",a[i][j]);
 }
}
 

 


                                马踏棋盘问题


#include <stdio.h>
#define N 5
void main(){
 int x,y;
 void horse(int i,int j);
 printf("Please input start position:");
 scanf("%d%d",&x,&y);
 horse(x-1,y-1);
}
void horse(int i,int j){
 int a[N][N]={0},start=0,
  h[]={1,2,2,1,-1,-2,-2,-1},
  v[]={2,1,-1,-2,2,1,-1,-2},
  save[N*N]={0},posnum=0,ti,tj,count=0;
 int jump(int i,int j,int a[N][N]);
 void outplan(int a[N][N]);
 a[i][j]=posnum+1;
 while(posnum>=0){
  ti=i;tj=j;
  for(start=save[posnum];start<8;++start){
   ti+=h[start];tj+=v[start];
   if(jump(ti,tj,a))
    break;
   ti-=h[start];tj-=v[start];
  }
  if(start<8){
   save[posnum]=start;
   a[ti][tj]=++posnum+1;
   i=ti;j=tj;save[posnum]=0;
   if(posnum==N*N-1){
    //outplan(a);
    count++;
   }
  }
  else{
   a[i][j]=0;
   posnum--;
   i-=h[save[posnum>;j-=v[save[posnum>;
   save[posnum]++;
  }
 }
 printf("%5d",count);
}
int jump(int i,int j,int a[N][N]){
 if(i<N&&i>=0&&j<N&&j>=0&&a[i][j]==0)
  return 1;
 return 0;
}
void outplan(int a[N][N]){
 int i,j;
 for(i=0;i<N;i++){
  for(j=0;j<N;j++)
   printf("%3d",a[i][j]);
  printf("\n");
 }
 printf("\n");
 //getchar();
}
用回溯法得到所有的解,但效率较低,只能算出5行5列的

 


Platform: | Size: 4395 | Author: good@588 | Hits:

[JSP/Javazhaopai

Description: Java: 在n 张扑克牌中找出顺子 题目是这样的:有n张扑克牌,每张牌的取值范围是:2,3,4,5,6,7,8,9,10,J,Q,K,A。在这n张牌中找出顺子(5张及5张以上的连续的牌),并将这些顺子打印出来。 思路:我的思路其实很简单,首先就是要去掉重复的牌,因为同样的顺子之算一个,显然JAVA中的Set很适合这个工作。同时又需要对这些牌进行排序,毫无疑问就是TreeSet了。然后从小到大遍历这些牌,并设置一个计数器count。若发现连续的牌,则count++;若发现不连续的,分2中情况:若count>4,则找到了一个顺子,存起来;反之则什么都不做。然后count=1,从新开始找顺子。下面就是代码:
Platform: | Size: 1528 | Author: yy | Hits:

[Other systemspfc_NR

Description: % 该Matlab程序基于牛顿-拉夫逊算法,用于计算已知导纳矩阵、PQ节点、PV节点、平衡节点(UA)的电力网络潮流 % U - 各节点母线电压 S - 各节点注入功率 S_net - 电力网络总损耗 % PQ_P - 实算PQ节点注入有功功率 PQ_Q - 实算PQ节点注入无功功率 % delt_PQ_P - 实算PQ节点有功功率修正值 delt_PQ_Q -实算PQ节点无功功率修正值 % delt_UA_P - 实平衡节点有功功率修正值 delt_U_2 - 实平衡节点电压平方修正值 % delt_PQV - 实算P Q U^2修正值 J - 雅可比矩阵 % e - 电压实部 f - 电压虚部 delt_ef - 电压实部与虚部修正值- The Matlab program based on the Newton- Raphson algorithm is used to calculate the admittance matrix is known, PQ node, PV node, the node balance (UA) the trend of the electricity networks U- the node bus voltage S- each node injection power S_net-- The total loss of electric power networks PQ_P- operator PQ is injected into active nodes PQ_Q- operator PQ is injected reactive power node delt_PQ_P- is considered the correct value of active power PQ node delt_PQ_Q- really count PQ node reactive power to amend the value of delt_UA_P- real active power balance of the correct value of the node delt_U_2- node voltage balance is the correct value of the square of delt_PQV- really count PQU ^ 2 the correct value of J- Jacobian matrix e- voltage real part f- the imaginary part of voltage delt_ef- voltage real part and imaginary part of the amendment value
Platform: | Size: 7168 | Author: mmcc | Hits:

[JSP/JavaCount(JSP)

Description: 刚学JAVA不到一个月,老师叫我们做一个计算器,实现基本功能就可以。于是就写了这个,以APPLET形式写的,仅供参考。-just learning Java less than a month, the teacher told us to do a calculator to achieve basic functions can be. So write this, write to form the APPLET, for information purposes only.
Platform: | Size: 20480 | Author: 薛基 | Hits:

[Other21-8

Description: /* 范例:21-8 自定义例外类 */ 当读者输入y的数值是0的话将会发生异常,并激活异常处理类 程序执行结果﹕ Project p21-8.exe raised exception class DividByZero with message Exception Object Address: 0x69346A . Process stopped. Use Step or Run to continue. Please Input Two Numbers,i除以j, i/j: 5 0 算数异常,x不能除以0,这是自定义异常类! 按Enter键继续... -/* Example :21-8 custom exception class*/When readers enter the y value is 0, then there will be abnormal, and abnormal activation of procedures to deal with the results of the implementation type: Project p21-8.exe raised exception class DividByZero with message Exception Object Address: 0x69346A. Process stopped. Use Step or Run to continue.Please Input Two Numbers, i divided by j, i/j: 50 count abnormal, x can not be divided by 0, this is a custom exception classes! press Enter key to continue. ..
Platform: | Size: 1024 | Author: | Hits:

[JSP/Javazhaopai

Description: Java: 在n 张扑克牌中找出顺子 题目是这样的:有n张扑克牌,每张牌的取值范围是:2,3,4,5,6,7,8,9,10,J,Q,K,A。在这n张牌中找出顺子(5张及5张以上的连续的牌),并将这些顺子打印出来。 思路:我的思路其实很简单,首先就是要去掉重复的牌,因为同样的顺子之算一个,显然JAVA中的Set很适合这个工作。同时又需要对这些牌进行排序,毫无疑问就是TreeSet了。然后从小到大遍历这些牌,并设置一个计数器count。若发现连续的牌,则count++;若发现不连续的,分2中情况:若count>4,则找到了一个顺子,存起来;反之则什么都不做。然后count=1,从新开始找顺子。下面就是代码:
Platform: | Size: 1024 | Author: yy | Hits:

[Data structsJman

Description: Visual 开发 希望对你们有帮助 public static int Rom(int n, int m)//双寄或双偶 { int count = 0 //第一排Y坐标上要几个 if (n < m) { for (int i = 1 i <= n i = i + 2) { count++ } } else { for (int j = 1 j <= m j = j + 2) { count++ } } return count }-Visual development of hope for your help public static int Rom (int n, int m)// double pin or dual dual (int count = 0// first row Y coordinates to a number if (n <m) (for ( int i = 1 i <= ni = i+ 2) (count++)) else (for (int j = 1 j <= mj = j+ 2) (count++)) return count)
Platform: | Size: 1024 | Author: json | Hits:

[CSharpGemBox.ExcelLite

Description: 导出Excel组件(B/S或C/S都可以用) using GemBox.ExcelLite //引用文件 ExcelFile excelFile = new ExcelFile() ExcelWorksheet sheet = excelFile.Worksheets.Add("WolfSpider") int columns = dataGridView1.Columns.Count int rows = dataGridView1.Rows.Count for (int j = 0 j < columns j++ ) { sheet.Cells[0, j].Value = dataGridView1.Columns[j].HeaderText } for (int i = 1 i <= rows i++) { for (int j = 0 j < columns j++) { sheet.Cells[i, j].Value = dataGridView1[j, i-1].Value } } excelFile.SaveXls("./guyun.xls") //这里的文件名可以任意定义 -Excel export component (B/S or C/S can be used) using GemBox.ExcelLite // reference document ExcelFile excelFile = new ExcelFile () ExcelWorksheet sheet = excelFile.Worksheets.Add ( " WolfSpider" ) int columns = dataGridView1.Columns.Count int rows = dataGridView1.Rows.Count for (int j = 0 j < columns j++) (sheet.Cells [0, j]. Value = dataGridView1.Columns [j]. HeaderText ) for (int i = 1 i < = rows i++) (for (int j = 0 j < columns j++) (sheet.Cells [i, j]. Value = dataGridView1 [j, i-1]. Value )) excelFile.SaveXls ( " ./guyun.xls" ) // here the file name can be defined
Platform: | Size: 2094080 | Author: lclc88com | Hits:

[Windows Developdist

Description: 问题描述: 给定m个整数组成的向量A, , ,和另一个由n个整数1 2 , , , m a a L a i a ≤m 1≤ i ≤m 组成的向量B, , 。向量A和B之间的距离dist定义为: 1 2 , , , n b b L b i b ≤ n 1≤ i ≤ n ( ) { }。1 ,1 , min i m j n i j dist A B a b ≤ ≤ ≤ ≤ = − 向量距离问题要求给定向量A和B的距离。 例如,当m=5,n=5,相应向量A为:(-5,3,-5,2,4),向量B为:(-2,-3,-2,-3,-1) 时,dist(A, B) = 2。 编程任务: 对于给定的m 个整数组成的向量A, , ,和另一个由n 1 2 , , , m a a L a i a ≤m 1≤ i ≤m 个整数组成的向量B, , ,试设计一个O(m + n)时间算法,计1 2 , , , n b b L b i b ≤ n 1≤ i ≤ n 算给定向量A和B的距离。 数据输入: 由文件input.txt提供输入数据。文件的第1行有2个正整数m和n。第2行是整数向量A: 。第3行是整数向量B: 。1 2 , , , m a a L a 1 2 , , , n b b L b 结果输出: 程序运行结束时,将计算出的向量A和B的距离输出到output.txt中。 输入示例输出示例 input.txt output.txt 5 5 -5 3 -5 2 4 -2 -3 -2 -3 -1 2-Problem description: A given integer m, composed of a vector A,,, and another by the n integers 1 2,,, maa L aia ≤ m 1 ≤ i ≤ m Vector composed of B,,. Vector between A and B is defined as dist from: 1 2,,, nbb L bib ≤ n 1 ≤ i ≤ n () (). 1, 1 , Min i m j n i j dist A B a b ≤ ≤ ≤ ≤ =-- Vector directed away from the issue of the volume of requests to the distance between A and B. For example, when m = 5, n = 5, corresponding to vector A: (-5,3,-5,2,4), vector B is: (-2,-3,-2,-3,-1) When, dist (A, B) = 2. Programming tasks: For a given integer m, composed of a vector A,,, and another by the n 1 2,,, maa L aia ≤ m 1 ≤ i ≤ m Integral component of the vector B,,, try to design a O (m+ n) time algorithm, namely 1 2,,, nbb L bib ≤ n 1 ≤ i ≤ n Directional traffic count to the distance between A and B. Data entry: Provided by the input data file input.txt. Line 1 of the document are two positive integers m and n. Line 2 is an integer vector A: . Line 3 is an integer vector
Platform: | Size: 776192 | Author: skyalone | Hits:

[Chess Poker gamesBlackjack

Description: 21点一般用到1-8副牌。庄家给每个玩家发两张牌,牌面朝上;给自己发两张牌,一张牌面朝上(叫明牌),一张牌面朝下(叫暗牌)。大家手中扑克点数的计算是:K、Q、J 和 10 牌都算作 10 点。 A 牌既可算作1 点也可算作11 点,由玩家自己决定。其余所有2 至9 牌均按其原面值计算。首先玩家开始要牌,如果玩家拿到的前两张牌是一张 A 和一张10点牌,就拥有黑杰克 (Blackjack);此时,如果庄家没有黑杰克,玩家就能赢得2倍的赌金(1赔2)。没有黑杰克的玩家可以继续拿牌,可以随意要多少张。目的是尽量往21点靠,靠得越近越好,最好就是21点了。在要牌的过程中,如果所有的牌加起来超过21点,玩家就输了——叫爆掉(Bust),游戏也就结束了。假如玩家没爆掉,又决定不再要牌了,这时庄家就把他的那张暗牌打开来。庄家根据自己的情况拿牌,一般到17点或17点以上不再拿牌,但也有可能15到16点甚至12到13点就不再拿牌或者18到19点继续拿牌。假如庄家爆掉了,那他就输了。假如他没爆掉,那么你就与他比点数大小,大为赢。一样的点数为平手,你可以把你的赌注拿回来。-21:00 General used the cards 1-8. The dealer to each player two cards, dealt face up to their own two cards issued, a card face up (called the winning numbers), a card face down (called the dark card). We calculated the hands of poker points: K, Q, J, and 10 cards are counted as 10 points. A card can count as 1 point can also be counted as 11 points by the players to decide. All the remaining 2 to 9 licenses according to its original par value. First, players began to license, if the player got the first two cards is a A and a 10-point card to a black Jack (Blackjack) this point, if the dealer does not Black Jack, the player will win 2 times Sweepstakes (1 lost 2). Black Jack, the player can not continue to take the card, feel free to how many. Our objective is to rely on to 21:00, close together as possible, the best is 21 o clock. To license the process, if all the cards add up to more than 21 points, players lose- call ringing off the hook (Bust), the game is over. If the players
Platform: | Size: 2048 | Author: 灏潍 | Hits:

[Windows Develophanoicx

Description: 汉诺塔源码C# nt width = (int)((panelHanoi.Width / 3 - offset)*((float)hanoiData.diskList[key][j]/hanoiData.diskCount))+offset int left=(int)(x-width/2) int height=20 int top=panelHanoi.Height-(hanoiData.diskList[key].Count-j)*height e.Graphics.FillRectangle(new SolidBrush(Color.Blue), new Rectangle(left, top, width, height-2)) e.Graphics.DrawString(hanoiData.diskList[key][j].ToString(), this.Font, new SolidBrush(Color.White), left, top) } }-nt width = (int)((panelHanoi.Width/3- offset)*((float)hanoiData.diskList[key][j]/hanoiData.diskCount))+offset int left=(int)(x-width/2) int height=20 int top=panelHanoi.Height-(hanoiData.diskList[key].Count-j)*height e.Graphics.FillRectangle(new SolidBrush(Color.Blue), new Rectangle(left, top, width, height-2)) e.Graphics.DrawString(hanoiData.diskList[key][j].ToString(), this.Font, new SolidBrush(Color.White), left, top) } }
Platform: | Size: 68608 | Author: zlqiufeng | Hits:

[Game Programgame_of_21_point

Description: 21点游戏规则:庄家给每个玩家发两张牌,牌面朝上;给自己发两张牌,一张牌面朝上(叫明牌),一张牌面朝下(叫暗牌)。大家手中扑克点数的计算是:K、Q、J 和 10 牌都算作 10 点。 A 牌既可算作1 点也可算作11 点,由玩家自己决定。其余所有2 至9 牌均按其原面值计算。目的是尽量往21点靠,靠得越近越好,最好就是21点了。在要牌的过程中,如果所有的牌加起来超过21点,玩家就输了——叫爆掉(Bust),游戏也就结束了。假如玩家没爆掉,又决定不再要牌了,这时庄家就把他的那张暗牌打开来。假如他现在的两张牌加起来小于或等于16点(Hit),他就必须继续给他自己发牌(不管他的点数是否比你大),一直发到他的点数大于等于17点为止。庄家在给自己发牌的过程中,假如他爆掉了,那他就输了。假如他没爆掉,那么你就与他比点数大小,大为赢。一样的点数为平手。-Blackjack game rules: banker to each player hair two CARDS, CARDS face, Give oneself to send two card, a piece of card face (called Ming card), CARDS face down (called dark card). Everybody hand poker points calculation is: K, qq, J and 10 CARDS are counted as 10 PM. A card can be counted as 1 point also can count 11 PM, by the player s own decision. All the CARDS are 2 to 9 according to its original value calculation. Purpose to do is go blackjack depend, rely on the nearly more, it is best to 21 points. In the process of brand, if all the brand added up to more than 21 points, the player will have lost-- called overflowing (Bust), the game is over. If the player doesn t overflowing and decided not to brand, when banker took him that piece of dark card to open. If he is now the two card added up to less than or equal to 16 points (Hit), he must continue to give himself a board (no matter whether his points larger than you), has been sent him greater than or equal to the points of 17 p
Platform: | Size: 2449408 | Author: 叶zp | Hits:

[Game Programyoulingcao

Description: 计算24是流行的扑克游戏。其方法是任意取出4张牌,A J Q K 王牌 算 1,其它牌按点数计算,花色不计。 目标是通过加、减、乘、除和括号最终算出24。设计一个程序,输入4个数字(1~10),则列出所有可能计算 结果为24的方案。-Calculation of 24 is a popular poker game. The method is to remove any 4 cards, AJQK ace count 1, calculated in points other brand, color do not count. Goal is to add, subtract, multiply, divide and calculate the end brackets 24. Design a program, enter 4 digits (1 ~ 10), lists all possible to calculate The results for the 24 programs.
Platform: | Size: 243712 | Author: 周建 | Hits:

[matlab111

Description: function pi = solve2(count,m,cc) 借助布冯投针实验 仿真求pi的值 pi=0 frq=0 randNo = binornd(1,cc,1,m) pro=zeros(1,count) for j=1:count for i = 1:m if randNo(1,i) == 1 frq = frq + 1 end pro(i) = frq/i end pi = (2*m)/frq pro(j) = pi end pro = pro,num =1:count plot(num,pro) -function pi = solve2 (count, m, cc) to vote with Buffon needle experiment simulation find the value of pi pi = 0 frq = 0 randNo = binornd (1, cc, 1, m) pro = zeros (1, count) for j = 1: count for i = 1: m if randNo (1, i) == 1 frq = frq+ 1 end pro (i) = frq/i end pi = (2* m )/frq pro (j) = pi end pro = pro, num = 1: count plot (num, pro)
Platform: | Size: 1024 | Author: 22323 | Hits:

[JSP/JavaCount

Description: package Test3 interface Shape { public abstract double getArea() public static final double PI=3.14 //【代码一】:定义求形状面积的抽象方法 } class Triangle implements Shape { private double a private double b private double c public Triangle(int i, int j, int k) { a = i b = j c = k } public double getArea(){ return Math.sqrt(((a+b+c)/2)*(((a+b+c)/2)-a)*(((a+b+c)/2)-b)*(((a+b+c)/2)-c)) }//【代码二】:定义三角形 } class Rectangle implements Shape { private double a private double b public Rectangle(int i, int j) { a = i b = j } public double getArea(){ return a*b -package Test3 interface Shape {public abstract double getArea () public static final double PI = 3.14 // A】 【code: find the definition of the abstract shapes approach the area} class Triangle implements Shape {private double a private double b private double c public Triangle (int i, int j, int k) {a = i b = j c = k } public double getArea () {return Math.sqrt (((a+ b+ c)/2 )*((( a+ b+ c)/2)-a )*((( a+ b+ c)/2)-b )*((( a+ b+ c)/2)-c)) }// Second】 【code: define a triangle} class Rectangle implements Shape {private double a private double b public Rectangle (int i, int j) {a = i b = j } public double getArea () { return a* b
Platform: | Size: 1024 | Author: biaoger | Hits:

[Mathimatics-Numerical algorithmsDynamic_Programming

Description: 利用动态规划来完成找零钱问题 计一个动态规划算法如何解决找零问题,对1≤j≤L,计算出所有的C( n,j )。算法中只允许实用一个长度为L的数组。找出用钱的最小个数。 (2) 0<=k<=j i>=1 i<=n,maxint c(i,k)硬币枚数 -Dynamic programming problems to complete the count to keep the change a dynamic programming algorithm to solve the problem give change for 1 ≤ j ≤ L, to calculate all the C (n, j). Algorithm is only practical with a length L of the array. Find the minimum number of money. (2) 0 < = k < = ji> = 1 i < = n, maxint c (i, k) the number of gold coins
Platform: | Size: 901120 | Author: 钱民 | Hits:

[Otherchoose

Description: 用c++编写的选票系统,并可统计相关得票情况-#include <iostream> using namespace std struct Person//声明结构体类型Person; { char name[20] int count } int main() { Person leader[3]={"aaa",0,"bbb",0,"ccc",0} //定义Person类型的数组,内容为当前候选人的姓名及得票数; char leader_name[20] //leader_name为投票人所选的人姓名; int i,j for(i=0 i<10 i++) { cin>>leader_name //先后输入十张票上所选的人的姓名; for(j=0 j<3 j++) { if(strcmp(leader_name,leader[j].name)==0) leader[j].count++ //所选人与候选人的姓名相同,则该候选人的票数加1; } } cout<<endl double round for(i=0 i<3 i++) { round=leader[i].count/10 cout<<leader[i].name<<":"<<"得票数:"<<leader[i].count<<"得票率:"<<round<<endl } return 0 }
Platform: | Size: 854016 | Author: 盛雯雯 | Hits:

[MPIjacobi

Description: A: aij, 1<= i,j<=n b: 1<=i<=n x0: intial guess, 1<=i<=n tol: tolerance N maximum number of iterations k: number count of iteration Xm(:,k): X in each k iteration-Jacobi s method: In numerical linear algebra, the Jacobi method is an algorithm for determining the solutions of a system of linear equations with largest absolute values in each row and column dominated by the diagonal element. Each diagonal element is solved for, and an approximate value plugged in. The process is then iterated until it converges. This algorithm is a stripped-down version of the Jacobi transformation method of matrix diagonalization. The method is named after German mathematician Carl Gustav Jakob Jacobi. http://en.wikipedia.org/wiki/Jacobi_method
Platform: | Size: 1024 | Author: Eric Chou | Hits:

[SCM1-6.C

Description: 1-6单片机休眠模式练习,8种LED点亮模式,延时程序计算方法, 计数个数j = 延时时间/6*晶振频率 - 1-1-6 practice of microcontroller sleep mode, 8 kinds of LED light mode, delay the program to calculate, count the number of j = delay time /* crystal frequency- 1
Platform: | Size: 5120 | Author: badboy | Hits:
« 12 »

CodeBus www.codebus.net